ホーム › System.Search › SQLBindParam
SQLBindParam
関数SQL文のパラメータをバッファに割り当てる。
シグネチャ
// ODBC32.dll
#include <windows.h>
SHORT SQLBindParam(
void* StatementHandle,
WORD ParameterNumber,
SHORT ValueType,
SHORT ParameterType,
DWORD LengthPrecision,
SHORT ParameterScale,
void* ParameterValue,
INT* StrLen_or_Ind
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| StatementHandle | void* | inout |
| ParameterNumber | WORD | in |
| ValueType | SHORT | in |
| ParameterType | SHORT | in |
| LengthPrecision | DWORD | in |
| ParameterScale | SHORT | in |
| ParameterValue | void* | inout |
| StrLen_or_Ind | INT* | inout |
戻り値の型: SHORT
各言語での呼び出し定義
// ODBC32.dll
#include <windows.h>
SHORT SQLBindParam(
void* StatementHandle,
WORD ParameterNumber,
SHORT ValueType,
SHORT ParameterType,
DWORD LengthPrecision,
SHORT ParameterScale,
void* ParameterValue,
INT* StrLen_or_Ind
);[DllImport("ODBC32.dll", ExactSpelling = true)]
static extern short SQLBindParam(
IntPtr StatementHandle, // void* in/out
ushort ParameterNumber, // WORD
short ValueType, // SHORT
short ParameterType, // SHORT
uint LengthPrecision, // DWORD
short ParameterScale, // SHORT
IntPtr ParameterValue, // void* in/out
ref int StrLen_or_Ind // INT* in/out
);<DllImport("ODBC32.dll", ExactSpelling:=True)>
Public Shared Function SQLBindParam(
StatementHandle As IntPtr, ' void* in/out
ParameterNumber As UShort, ' WORD
ValueType As Short, ' SHORT
ParameterType As Short, ' SHORT
LengthPrecision As UInteger, ' DWORD
ParameterScale As Short, ' SHORT
ParameterValue As IntPtr, ' void* in/out
ByRef StrLen_or_Ind As Integer ' INT* in/out
) As Short
End Function' StatementHandle : void* in/out
' ParameterNumber : WORD
' ValueType : SHORT
' ParameterType : SHORT
' LengthPrecision : DWORD
' ParameterScale : SHORT
' ParameterValue : void* in/out
' StrLen_or_Ind : INT* in/out
Declare PtrSafe Function SQLBindParam Lib "odbc32" ( _
ByVal StatementHandle As LongPtr, _
ByVal ParameterNumber As Integer, _
ByVal ValueType As Integer, _
ByVal ParameterType As Integer, _
ByVal LengthPrecision As Long, _
ByVal ParameterScale As Integer, _
ByVal ParameterValue As LongPtr, _
ByRef StrLen_or_Ind As Long) As Integer
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SQLBindParam = ctypes.windll.odbc32.SQLBindParam
SQLBindParam.restype = ctypes.c_short
SQLBindParam.argtypes = [
ctypes.POINTER(None), # StatementHandle : void* in/out
ctypes.c_ushort, # ParameterNumber : WORD
ctypes.c_short, # ValueType : SHORT
ctypes.c_short, # ParameterType : SHORT
wintypes.DWORD, # LengthPrecision : DWORD
ctypes.c_short, # ParameterScale : SHORT
ctypes.POINTER(None), # ParameterValue : void* in/out
ctypes.POINTER(ctypes.c_int), # StrLen_or_Ind : INT* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ODBC32.dll')
SQLBindParam = Fiddle::Function.new(
lib['SQLBindParam'],
[
Fiddle::TYPE_VOIDP, # StatementHandle : void* in/out
-Fiddle::TYPE_SHORT, # ParameterNumber : WORD
Fiddle::TYPE_SHORT, # ValueType : SHORT
Fiddle::TYPE_SHORT, # ParameterType : SHORT
-Fiddle::TYPE_INT, # LengthPrecision : DWORD
Fiddle::TYPE_SHORT, # ParameterScale : SHORT
Fiddle::TYPE_VOIDP, # ParameterValue : void* in/out
Fiddle::TYPE_VOIDP, # StrLen_or_Ind : INT* in/out
],
Fiddle::TYPE_SHORT)#[link(name = "odbc32")]
extern "system" {
fn SQLBindParam(
StatementHandle: *mut (), // void* in/out
ParameterNumber: u16, // WORD
ValueType: i16, // SHORT
ParameterType: i16, // SHORT
LengthPrecision: u32, // DWORD
ParameterScale: i16, // SHORT
ParameterValue: *mut (), // void* in/out
StrLen_or_Ind: *mut i32 // INT* in/out
) -> i16;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ODBC32.dll")]
public static extern short SQLBindParam(IntPtr StatementHandle, ushort ParameterNumber, short ValueType, short ParameterType, uint LengthPrecision, short ParameterScale, IntPtr ParameterValue, ref int StrLen_or_Ind);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ODBC32_SQLBindParam' -Namespace Win32 -PassThru
# $api::SQLBindParam(StatementHandle, ParameterNumber, ValueType, ParameterType, LengthPrecision, ParameterScale, ParameterValue, StrLen_or_Ind)#uselib "ODBC32.dll"
#func global SQLBindParam "SQLBindParam" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; SQLBindParam StatementHandle, ParameterNumber, ValueType, ParameterType, LengthPrecision, ParameterScale, ParameterValue, varptr(StrLen_or_Ind) ; 戻り値は stat
; StatementHandle : void* in/out -> "sptr"
; ParameterNumber : WORD -> "sptr"
; ValueType : SHORT -> "sptr"
; ParameterType : SHORT -> "sptr"
; LengthPrecision : DWORD -> "sptr"
; ParameterScale : SHORT -> "sptr"
; ParameterValue : void* in/out -> "sptr"
; StrLen_or_Ind : INT* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "ODBC32.dll" #cfunc global SQLBindParam "SQLBindParam" sptr, int, int, int, int, int, sptr, var ; res = SQLBindParam(StatementHandle, ParameterNumber, ValueType, ParameterType, LengthPrecision, ParameterScale, ParameterValue, StrLen_or_Ind) ; StatementHandle : void* in/out -> "sptr" ; ParameterNumber : WORD -> "int" ; ValueType : SHORT -> "int" ; ParameterType : SHORT -> "int" ; LengthPrecision : DWORD -> "int" ; ParameterScale : SHORT -> "int" ; ParameterValue : void* in/out -> "sptr" ; StrLen_or_Ind : INT* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ODBC32.dll" #cfunc global SQLBindParam "SQLBindParam" sptr, int, int, int, int, int, sptr, sptr ; res = SQLBindParam(StatementHandle, ParameterNumber, ValueType, ParameterType, LengthPrecision, ParameterScale, ParameterValue, varptr(StrLen_or_Ind)) ; StatementHandle : void* in/out -> "sptr" ; ParameterNumber : WORD -> "int" ; ValueType : SHORT -> "int" ; ParameterType : SHORT -> "int" ; LengthPrecision : DWORD -> "int" ; ParameterScale : SHORT -> "int" ; ParameterValue : void* in/out -> "sptr" ; StrLen_or_Ind : INT* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; SHORT SQLBindParam(void* StatementHandle, WORD ParameterNumber, SHORT ValueType, SHORT ParameterType, DWORD LengthPrecision, SHORT ParameterScale, void* ParameterValue, INT* StrLen_or_Ind) #uselib "ODBC32.dll" #cfunc global SQLBindParam "SQLBindParam" intptr, int, int, int, int, int, intptr, var ; res = SQLBindParam(StatementHandle, ParameterNumber, ValueType, ParameterType, LengthPrecision, ParameterScale, ParameterValue, StrLen_or_Ind) ; StatementHandle : void* in/out -> "intptr" ; ParameterNumber : WORD -> "int" ; ValueType : SHORT -> "int" ; ParameterType : SHORT -> "int" ; LengthPrecision : DWORD -> "int" ; ParameterScale : SHORT -> "int" ; ParameterValue : void* in/out -> "intptr" ; StrLen_or_Ind : INT* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; SHORT SQLBindParam(void* StatementHandle, WORD ParameterNumber, SHORT ValueType, SHORT ParameterType, DWORD LengthPrecision, SHORT ParameterScale, void* ParameterValue, INT* StrLen_or_Ind) #uselib "ODBC32.dll" #cfunc global SQLBindParam "SQLBindParam" intptr, int, int, int, int, int, intptr, intptr ; res = SQLBindParam(StatementHandle, ParameterNumber, ValueType, ParameterType, LengthPrecision, ParameterScale, ParameterValue, varptr(StrLen_or_Ind)) ; StatementHandle : void* in/out -> "intptr" ; ParameterNumber : WORD -> "int" ; ValueType : SHORT -> "int" ; ParameterType : SHORT -> "int" ; LengthPrecision : DWORD -> "int" ; ParameterScale : SHORT -> "int" ; ParameterValue : void* in/out -> "intptr" ; StrLen_or_Ind : INT* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
odbc32 = windows.NewLazySystemDLL("ODBC32.dll")
procSQLBindParam = odbc32.NewProc("SQLBindParam")
)
// StatementHandle (void* in/out), ParameterNumber (WORD), ValueType (SHORT), ParameterType (SHORT), LengthPrecision (DWORD), ParameterScale (SHORT), ParameterValue (void* in/out), StrLen_or_Ind (INT* in/out)
r1, _, err := procSQLBindParam.Call(
uintptr(StatementHandle),
uintptr(ParameterNumber),
uintptr(ValueType),
uintptr(ParameterType),
uintptr(LengthPrecision),
uintptr(ParameterScale),
uintptr(ParameterValue),
uintptr(StrLen_or_Ind),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // SHORTfunction SQLBindParam(
StatementHandle: Pointer; // void* in/out
ParameterNumber: Word; // WORD
ValueType: Smallint; // SHORT
ParameterType: Smallint; // SHORT
LengthPrecision: DWORD; // DWORD
ParameterScale: Smallint; // SHORT
ParameterValue: Pointer; // void* in/out
StrLen_or_Ind: Pointer // INT* in/out
): Smallint; stdcall;
external 'ODBC32.dll' name 'SQLBindParam';result := DllCall("ODBC32\SQLBindParam"
, "Ptr", StatementHandle ; void* in/out
, "UShort", ParameterNumber ; WORD
, "Short", ValueType ; SHORT
, "Short", ParameterType ; SHORT
, "UInt", LengthPrecision ; DWORD
, "Short", ParameterScale ; SHORT
, "Ptr", ParameterValue ; void* in/out
, "Ptr", StrLen_or_Ind ; INT* in/out
, "Short") ; return: SHORT●SQLBindParam(StatementHandle, ParameterNumber, ValueType, ParameterType, LengthPrecision, ParameterScale, ParameterValue, StrLen_or_Ind) = DLL("ODBC32.dll", "int SQLBindParam(void*, int, int, int, dword, int, void*, void*)")
# 呼び出し: SQLBindParam(StatementHandle, ParameterNumber, ValueType, ParameterType, LengthPrecision, ParameterScale, ParameterValue, StrLen_or_Ind)
# StatementHandle : void* in/out -> "void*"
# ParameterNumber : WORD -> "int"
# ValueType : SHORT -> "int"
# ParameterType : SHORT -> "int"
# LengthPrecision : DWORD -> "dword"
# ParameterScale : SHORT -> "int"
# ParameterValue : void* in/out -> "void*"
# StrLen_or_Ind : INT* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。