ホーム › System.Search › SQLBindParameter
SQLBindParameter
関数SQL文のパラメータに変数とデータ型を結び付ける。
シグネチャ
// ODBC32.dll
#include <windows.h>
SHORT SQLBindParameter(
void* hstmt,
WORD ipar,
SHORT fParamType,
SHORT fCType,
SHORT fSqlType,
DWORD cbColDef,
SHORT ibScale,
void* rgbValue,
INT cbValueMax,
INT* pcbValue
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hstmt | void* | inout | パラメータをバインドする対象のステートメントハンドル。 |
| ipar | WORD | in | パラメータ番号。1始まりで指定する。 |
| fParamType | SHORT | in | パラメータの入出力種別。SQL_PARAM_INPUT/OUTPUT/INPUT_OUTPUT。 |
| fCType | SHORT | in | アプリ側バッファのCデータ型。SQL_C_*定数を指定する。 |
| fSqlType | SHORT | in | パラメータのSQLデータ型を指定する。 |
| cbColDef | DWORD | in | 列のサイズまたは精度を指定する。 |
| ibScale | SHORT | in | 小数点以下桁数(スケール)を指定する。 |
| rgbValue | void* | inout | パラメータ値を格納するバッファへのポインタ。 |
| cbValueMax | INT | in | rgbValueバッファのバイト長。 |
| pcbValue | INT* | inout | 値のバイト長またはSQL_NULL_DATA等の標識を保持するポインタ。 |
戻り値の型: SHORT
各言語での呼び出し定義
// ODBC32.dll
#include <windows.h>
SHORT SQLBindParameter(
void* hstmt,
WORD ipar,
SHORT fParamType,
SHORT fCType,
SHORT fSqlType,
DWORD cbColDef,
SHORT ibScale,
void* rgbValue,
INT cbValueMax,
INT* pcbValue
);[DllImport("ODBC32.dll", ExactSpelling = true)]
static extern short SQLBindParameter(
IntPtr hstmt, // void* in/out
ushort ipar, // WORD
short fParamType, // SHORT
short fCType, // SHORT
short fSqlType, // SHORT
uint cbColDef, // DWORD
short ibScale, // SHORT
IntPtr rgbValue, // void* in/out
int cbValueMax, // INT
ref int pcbValue // INT* in/out
);<DllImport("ODBC32.dll", ExactSpelling:=True)>
Public Shared Function SQLBindParameter(
hstmt As IntPtr, ' void* in/out
ipar As UShort, ' WORD
fParamType As Short, ' SHORT
fCType As Short, ' SHORT
fSqlType As Short, ' SHORT
cbColDef As UInteger, ' DWORD
ibScale As Short, ' SHORT
rgbValue As IntPtr, ' void* in/out
cbValueMax As Integer, ' INT
ByRef pcbValue As Integer ' INT* in/out
) As Short
End Function' hstmt : void* in/out
' ipar : WORD
' fParamType : SHORT
' fCType : SHORT
' fSqlType : SHORT
' cbColDef : DWORD
' ibScale : SHORT
' rgbValue : void* in/out
' cbValueMax : INT
' pcbValue : INT* in/out
Declare PtrSafe Function SQLBindParameter Lib "odbc32" ( _
ByVal hstmt As LongPtr, _
ByVal ipar As Integer, _
ByVal fParamType As Integer, _
ByVal fCType As Integer, _
ByVal fSqlType As Integer, _
ByVal cbColDef As Long, _
ByVal ibScale As Integer, _
ByVal rgbValue As LongPtr, _
ByVal cbValueMax As Long, _
ByRef pcbValue As Long) As Integer
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SQLBindParameter = ctypes.windll.odbc32.SQLBindParameter
SQLBindParameter.restype = ctypes.c_short
SQLBindParameter.argtypes = [
ctypes.POINTER(None), # hstmt : void* in/out
ctypes.c_ushort, # ipar : WORD
ctypes.c_short, # fParamType : SHORT
ctypes.c_short, # fCType : SHORT
ctypes.c_short, # fSqlType : SHORT
wintypes.DWORD, # cbColDef : DWORD
ctypes.c_short, # ibScale : SHORT
ctypes.POINTER(None), # rgbValue : void* in/out
ctypes.c_int, # cbValueMax : INT
ctypes.POINTER(ctypes.c_int), # pcbValue : INT* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ODBC32.dll')
SQLBindParameter = Fiddle::Function.new(
lib['SQLBindParameter'],
[
Fiddle::TYPE_VOIDP, # hstmt : void* in/out
-Fiddle::TYPE_SHORT, # ipar : WORD
Fiddle::TYPE_SHORT, # fParamType : SHORT
Fiddle::TYPE_SHORT, # fCType : SHORT
Fiddle::TYPE_SHORT, # fSqlType : SHORT
-Fiddle::TYPE_INT, # cbColDef : DWORD
Fiddle::TYPE_SHORT, # ibScale : SHORT
Fiddle::TYPE_VOIDP, # rgbValue : void* in/out
Fiddle::TYPE_INT, # cbValueMax : INT
Fiddle::TYPE_VOIDP, # pcbValue : INT* in/out
],
Fiddle::TYPE_SHORT)#[link(name = "odbc32")]
extern "system" {
fn SQLBindParameter(
hstmt: *mut (), // void* in/out
ipar: u16, // WORD
fParamType: i16, // SHORT
fCType: i16, // SHORT
fSqlType: i16, // SHORT
cbColDef: u32, // DWORD
ibScale: i16, // SHORT
rgbValue: *mut (), // void* in/out
cbValueMax: i32, // INT
pcbValue: *mut i32 // INT* in/out
) -> i16;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ODBC32.dll")]
public static extern short SQLBindParameter(IntPtr hstmt, ushort ipar, short fParamType, short fCType, short fSqlType, uint cbColDef, short ibScale, IntPtr rgbValue, int cbValueMax, ref int pcbValue);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ODBC32_SQLBindParameter' -Namespace Win32 -PassThru
# $api::SQLBindParameter(hstmt, ipar, fParamType, fCType, fSqlType, cbColDef, ibScale, rgbValue, cbValueMax, pcbValue)#uselib "ODBC32.dll"
#func global SQLBindParameter "SQLBindParameter" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; SQLBindParameter hstmt, ipar, fParamType, fCType, fSqlType, cbColDef, ibScale, rgbValue, cbValueMax, varptr(pcbValue) ; 戻り値は stat
; hstmt : void* in/out -> "sptr"
; ipar : WORD -> "sptr"
; fParamType : SHORT -> "sptr"
; fCType : SHORT -> "sptr"
; fSqlType : SHORT -> "sptr"
; cbColDef : DWORD -> "sptr"
; ibScale : SHORT -> "sptr"
; rgbValue : void* in/out -> "sptr"
; cbValueMax : INT -> "sptr"
; pcbValue : INT* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "ODBC32.dll" #cfunc global SQLBindParameter "SQLBindParameter" sptr, int, int, int, int, int, int, sptr, int, var ; res = SQLBindParameter(hstmt, ipar, fParamType, fCType, fSqlType, cbColDef, ibScale, rgbValue, cbValueMax, pcbValue) ; hstmt : void* in/out -> "sptr" ; ipar : WORD -> "int" ; fParamType : SHORT -> "int" ; fCType : SHORT -> "int" ; fSqlType : SHORT -> "int" ; cbColDef : DWORD -> "int" ; ibScale : SHORT -> "int" ; rgbValue : void* in/out -> "sptr" ; cbValueMax : INT -> "int" ; pcbValue : INT* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ODBC32.dll" #cfunc global SQLBindParameter "SQLBindParameter" sptr, int, int, int, int, int, int, sptr, int, sptr ; res = SQLBindParameter(hstmt, ipar, fParamType, fCType, fSqlType, cbColDef, ibScale, rgbValue, cbValueMax, varptr(pcbValue)) ; hstmt : void* in/out -> "sptr" ; ipar : WORD -> "int" ; fParamType : SHORT -> "int" ; fCType : SHORT -> "int" ; fSqlType : SHORT -> "int" ; cbColDef : DWORD -> "int" ; ibScale : SHORT -> "int" ; rgbValue : void* in/out -> "sptr" ; cbValueMax : INT -> "int" ; pcbValue : INT* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; SHORT SQLBindParameter(void* hstmt, WORD ipar, SHORT fParamType, SHORT fCType, SHORT fSqlType, DWORD cbColDef, SHORT ibScale, void* rgbValue, INT cbValueMax, INT* pcbValue) #uselib "ODBC32.dll" #cfunc global SQLBindParameter "SQLBindParameter" intptr, int, int, int, int, int, int, intptr, int, var ; res = SQLBindParameter(hstmt, ipar, fParamType, fCType, fSqlType, cbColDef, ibScale, rgbValue, cbValueMax, pcbValue) ; hstmt : void* in/out -> "intptr" ; ipar : WORD -> "int" ; fParamType : SHORT -> "int" ; fCType : SHORT -> "int" ; fSqlType : SHORT -> "int" ; cbColDef : DWORD -> "int" ; ibScale : SHORT -> "int" ; rgbValue : void* in/out -> "intptr" ; cbValueMax : INT -> "int" ; pcbValue : INT* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; SHORT SQLBindParameter(void* hstmt, WORD ipar, SHORT fParamType, SHORT fCType, SHORT fSqlType, DWORD cbColDef, SHORT ibScale, void* rgbValue, INT cbValueMax, INT* pcbValue) #uselib "ODBC32.dll" #cfunc global SQLBindParameter "SQLBindParameter" intptr, int, int, int, int, int, int, intptr, int, intptr ; res = SQLBindParameter(hstmt, ipar, fParamType, fCType, fSqlType, cbColDef, ibScale, rgbValue, cbValueMax, varptr(pcbValue)) ; hstmt : void* in/out -> "intptr" ; ipar : WORD -> "int" ; fParamType : SHORT -> "int" ; fCType : SHORT -> "int" ; fSqlType : SHORT -> "int" ; cbColDef : DWORD -> "int" ; ibScale : SHORT -> "int" ; rgbValue : void* in/out -> "intptr" ; cbValueMax : INT -> "int" ; pcbValue : INT* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
odbc32 = windows.NewLazySystemDLL("ODBC32.dll")
procSQLBindParameter = odbc32.NewProc("SQLBindParameter")
)
// hstmt (void* in/out), ipar (WORD), fParamType (SHORT), fCType (SHORT), fSqlType (SHORT), cbColDef (DWORD), ibScale (SHORT), rgbValue (void* in/out), cbValueMax (INT), pcbValue (INT* in/out)
r1, _, err := procSQLBindParameter.Call(
uintptr(hstmt),
uintptr(ipar),
uintptr(fParamType),
uintptr(fCType),
uintptr(fSqlType),
uintptr(cbColDef),
uintptr(ibScale),
uintptr(rgbValue),
uintptr(cbValueMax),
uintptr(pcbValue),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // SHORTfunction SQLBindParameter(
hstmt: Pointer; // void* in/out
ipar: Word; // WORD
fParamType: Smallint; // SHORT
fCType: Smallint; // SHORT
fSqlType: Smallint; // SHORT
cbColDef: DWORD; // DWORD
ibScale: Smallint; // SHORT
rgbValue: Pointer; // void* in/out
cbValueMax: Integer; // INT
pcbValue: Pointer // INT* in/out
): Smallint; stdcall;
external 'ODBC32.dll' name 'SQLBindParameter';result := DllCall("ODBC32\SQLBindParameter"
, "Ptr", hstmt ; void* in/out
, "UShort", ipar ; WORD
, "Short", fParamType ; SHORT
, "Short", fCType ; SHORT
, "Short", fSqlType ; SHORT
, "UInt", cbColDef ; DWORD
, "Short", ibScale ; SHORT
, "Ptr", rgbValue ; void* in/out
, "Int", cbValueMax ; INT
, "Ptr", pcbValue ; INT* in/out
, "Short") ; return: SHORT●SQLBindParameter(hstmt, ipar, fParamType, fCType, fSqlType, cbColDef, ibScale, rgbValue, cbValueMax, pcbValue) = DLL("ODBC32.dll", "int SQLBindParameter(void*, int, int, int, int, dword, int, void*, int, void*)")
# 呼び出し: SQLBindParameter(hstmt, ipar, fParamType, fCType, fSqlType, cbColDef, ibScale, rgbValue, cbValueMax, pcbValue)
# hstmt : void* in/out -> "void*"
# ipar : WORD -> "int"
# fParamType : SHORT -> "int"
# fCType : SHORT -> "int"
# fSqlType : SHORT -> "int"
# cbColDef : DWORD -> "dword"
# ibScale : SHORT -> "int"
# rgbValue : void* in/out -> "void*"
# cbValueMax : INT -> "int"
# pcbValue : INT* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "odbc32" fn SQLBindParameter(
hstmt: ?*anyopaque, // void* in/out
ipar: u16, // WORD
fParamType: i16, // SHORT
fCType: i16, // SHORT
fSqlType: i16, // SHORT
cbColDef: u32, // DWORD
ibScale: i16, // SHORT
rgbValue: ?*anyopaque, // void* in/out
cbValueMax: i32, // INT
pcbValue: [*c]i32 // INT* in/out
) callconv(std.os.windows.WINAPI) i16;proc SQLBindParameter(
hstmt: pointer, # void* in/out
ipar: uint16, # WORD
fParamType: int16, # SHORT
fCType: int16, # SHORT
fSqlType: int16, # SHORT
cbColDef: uint32, # DWORD
ibScale: int16, # SHORT
rgbValue: pointer, # void* in/out
cbValueMax: int32, # INT
pcbValue: ptr int32 # INT* in/out
): int16 {.importc: "SQLBindParameter", stdcall, dynlib: "ODBC32.dll".}pragma(lib, "odbc32");
extern(Windows)
short SQLBindParameter(
void* hstmt, // void* in/out
ushort ipar, // WORD
short fParamType, // SHORT
short fCType, // SHORT
short fSqlType, // SHORT
uint cbColDef, // DWORD
short ibScale, // SHORT
void* rgbValue, // void* in/out
int cbValueMax, // INT
int* pcbValue // INT* in/out
);ccall((:SQLBindParameter, "ODBC32.dll"), stdcall, Int16,
(Ptr{Cvoid}, UInt16, Int16, Int16, Int16, UInt32, Int16, Ptr{Cvoid}, Int32, Ptr{Int32}),
hstmt, ipar, fParamType, fCType, fSqlType, cbColDef, ibScale, rgbValue, cbValueMax, pcbValue)
# hstmt : void* in/out -> Ptr{Cvoid}
# ipar : WORD -> UInt16
# fParamType : SHORT -> Int16
# fCType : SHORT -> Int16
# fSqlType : SHORT -> Int16
# cbColDef : DWORD -> UInt32
# ibScale : SHORT -> Int16
# rgbValue : void* in/out -> Ptr{Cvoid}
# cbValueMax : INT -> Int32
# pcbValue : INT* in/out -> Ptr{Int32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int16_t SQLBindParameter(
void* hstmt,
uint16_t ipar,
int16_t fParamType,
int16_t fCType,
int16_t fSqlType,
uint32_t cbColDef,
int16_t ibScale,
void* rgbValue,
int32_t cbValueMax,
int32_t* pcbValue);
]]
local odbc32 = ffi.load("odbc32")
-- odbc32.SQLBindParameter(hstmt, ipar, fParamType, fCType, fSqlType, cbColDef, ibScale, rgbValue, cbValueMax, pcbValue)
-- hstmt : void* in/out
-- ipar : WORD
-- fParamType : SHORT
-- fCType : SHORT
-- fSqlType : SHORT
-- cbColDef : DWORD
-- ibScale : SHORT
-- rgbValue : void* in/out
-- cbValueMax : INT
-- pcbValue : INT* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('ODBC32.dll');
const SQLBindParameter = lib.func('__stdcall', 'SQLBindParameter', 'int16_t', ['void *', 'uint16_t', 'int16_t', 'int16_t', 'int16_t', 'uint32_t', 'int16_t', 'void *', 'int32_t', 'int32_t *']);
// SQLBindParameter(hstmt, ipar, fParamType, fCType, fSqlType, cbColDef, ibScale, rgbValue, cbValueMax, pcbValue)
// hstmt : void* in/out -> 'void *'
// ipar : WORD -> 'uint16_t'
// fParamType : SHORT -> 'int16_t'
// fCType : SHORT -> 'int16_t'
// fSqlType : SHORT -> 'int16_t'
// cbColDef : DWORD -> 'uint32_t'
// ibScale : SHORT -> 'int16_t'
// rgbValue : void* in/out -> 'void *'
// cbValueMax : INT -> 'int32_t'
// pcbValue : INT* in/out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("ODBC32.dll", {
SQLBindParameter: { parameters: ["pointer", "u16", "i16", "i16", "i16", "u32", "i16", "pointer", "i32", "pointer"], result: "i16" },
});
// lib.symbols.SQLBindParameter(hstmt, ipar, fParamType, fCType, fSqlType, cbColDef, ibScale, rgbValue, cbValueMax, pcbValue)
// hstmt : void* in/out -> "pointer"
// ipar : WORD -> "u16"
// fParamType : SHORT -> "i16"
// fCType : SHORT -> "i16"
// fSqlType : SHORT -> "i16"
// cbColDef : DWORD -> "u32"
// ibScale : SHORT -> "i16"
// rgbValue : void* in/out -> "pointer"
// cbValueMax : INT -> "i32"
// pcbValue : INT* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int16_t SQLBindParameter(
void* hstmt,
uint16_t ipar,
int16_t fParamType,
int16_t fCType,
int16_t fSqlType,
uint32_t cbColDef,
int16_t ibScale,
void* rgbValue,
int32_t cbValueMax,
int32_t* pcbValue);
C, "ODBC32.dll");
// $ffi->SQLBindParameter(hstmt, ipar, fParamType, fCType, fSqlType, cbColDef, ibScale, rgbValue, cbValueMax, pcbValue);
// hstmt : void* in/out
// ipar : WORD
// fParamType : SHORT
// fCType : SHORT
// fSqlType : SHORT
// cbColDef : DWORD
// ibScale : SHORT
// rgbValue : void* in/out
// cbValueMax : INT
// pcbValue : INT* in/out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Odbc32 extends StdCallLibrary {
Odbc32 INSTANCE = Native.load("odbc32", Odbc32.class);
short SQLBindParameter(
Pointer hstmt, // void* in/out
short ipar, // WORD
short fParamType, // SHORT
short fCType, // SHORT
short fSqlType, // SHORT
int cbColDef, // DWORD
short ibScale, // SHORT
Pointer rgbValue, // void* in/out
int cbValueMax, // INT
IntByReference pcbValue // INT* in/out
);
}@[Link("odbc32")]
lib LibODBC32
fun SQLBindParameter = SQLBindParameter(
hstmt : Void*, # void* in/out
ipar : UInt16, # WORD
fParamType : Int16, # SHORT
fCType : Int16, # SHORT
fSqlType : Int16, # SHORT
cbColDef : UInt32, # DWORD
ibScale : Int16, # SHORT
rgbValue : Void*, # void* in/out
cbValueMax : Int32, # INT
pcbValue : Int32* # INT* in/out
) : Int16
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef SQLBindParameterNative = Int16 Function(Pointer<Void>, Uint16, Int16, Int16, Int16, Uint32, Int16, Pointer<Void>, Int32, Pointer<Int32>);
typedef SQLBindParameterDart = int Function(Pointer<Void>, int, int, int, int, int, int, Pointer<Void>, int, Pointer<Int32>);
final SQLBindParameter = DynamicLibrary.open('ODBC32.dll')
.lookupFunction<SQLBindParameterNative, SQLBindParameterDart>('SQLBindParameter');
// hstmt : void* in/out -> Pointer<Void>
// ipar : WORD -> Uint16
// fParamType : SHORT -> Int16
// fCType : SHORT -> Int16
// fSqlType : SHORT -> Int16
// cbColDef : DWORD -> Uint32
// ibScale : SHORT -> Int16
// rgbValue : void* in/out -> Pointer<Void>
// cbValueMax : INT -> Int32
// pcbValue : INT* in/out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SQLBindParameter(
hstmt: Pointer; // void* in/out
ipar: Word; // WORD
fParamType: Smallint; // SHORT
fCType: Smallint; // SHORT
fSqlType: Smallint; // SHORT
cbColDef: DWORD; // DWORD
ibScale: Smallint; // SHORT
rgbValue: Pointer; // void* in/out
cbValueMax: Integer; // INT
pcbValue: Pointer // INT* in/out
): Smallint; stdcall;
external 'ODBC32.dll' name 'SQLBindParameter';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SQLBindParameter"
c_SQLBindParameter :: Ptr () -> Word16 -> Int16 -> Int16 -> Int16 -> Word32 -> Int16 -> Ptr () -> Int32 -> Ptr Int32 -> IO Int16
-- hstmt : void* in/out -> Ptr ()
-- ipar : WORD -> Word16
-- fParamType : SHORT -> Int16
-- fCType : SHORT -> Int16
-- fSqlType : SHORT -> Int16
-- cbColDef : DWORD -> Word32
-- ibScale : SHORT -> Int16
-- rgbValue : void* in/out -> Ptr ()
-- cbValueMax : INT -> Int32
-- pcbValue : INT* in/out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let sqlbindparameter =
foreign "SQLBindParameter"
((ptr void) @-> uint16_t @-> int16_t @-> int16_t @-> int16_t @-> uint32_t @-> int16_t @-> (ptr void) @-> int32_t @-> (ptr int32_t) @-> returning int16_t)
(* hstmt : void* in/out -> (ptr void) *)
(* ipar : WORD -> uint16_t *)
(* fParamType : SHORT -> int16_t *)
(* fCType : SHORT -> int16_t *)
(* fSqlType : SHORT -> int16_t *)
(* cbColDef : DWORD -> uint32_t *)
(* ibScale : SHORT -> int16_t *)
(* rgbValue : void* in/out -> (ptr void) *)
(* cbValueMax : INT -> int32_t *)
(* pcbValue : INT* in/out -> (ptr int32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library odbc32 (t "ODBC32.dll"))
(cffi:use-foreign-library odbc32)
(cffi:defcfun ("SQLBindParameter" sqlbind-parameter :convention :stdcall) :int16
(hstmt :pointer) ; void* in/out
(ipar :uint16) ; WORD
(f-param-type :int16) ; SHORT
(f-ctype :int16) ; SHORT
(f-sql-type :int16) ; SHORT
(cb-col-def :uint32) ; DWORD
(ib-scale :int16) ; SHORT
(rgb-value :pointer) ; void* in/out
(cb-value-max :int32) ; INT
(pcb-value :pointer)) ; INT* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SQLBindParameter = Win32::API::More->new('ODBC32',
'short SQLBindParameter(LPVOID hstmt, WORD ipar, short fParamType, short fCType, short fSqlType, DWORD cbColDef, short ibScale, LPVOID rgbValue, int cbValueMax, LPVOID pcbValue)');
# my $ret = $SQLBindParameter->Call($hstmt, $ipar, $fParamType, $fCType, $fSqlType, $cbColDef, $ibScale, $rgbValue, $cbValueMax, $pcbValue);
# hstmt : void* in/out -> LPVOID
# ipar : WORD -> WORD
# fParamType : SHORT -> short
# fCType : SHORT -> short
# fSqlType : SHORT -> short
# cbColDef : DWORD -> DWORD
# ibScale : SHORT -> short
# rgbValue : void* in/out -> LPVOID
# cbValueMax : INT -> int
# pcbValue : INT* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。