Win32 API 日本語リファレンス
ホームSystem.Search › SQLBindCol

SQLBindCol

関数
結果セットの列をアプリケーションのバッファに割り当てる。
DLLODBC32.dll呼出規約winapi

シグネチャ

// ODBC32.dll
#include <windows.h>

SHORT SQLBindCol(
    void* StatementHandle,
    WORD ColumnNumber,
    SHORT TargetType,
    void* TargetValue,   // optional
    INT BufferLength,
    INT* StrLen_or_Ind   // optional
);

パラメーター

名前方向
StatementHandlevoid*inout
ColumnNumberWORDin
TargetTypeSHORTin
TargetValuevoid*inoutoptional
BufferLengthINTin
StrLen_or_IndINT*inoutoptional

戻り値の型: SHORT

各言語での呼び出し定義

// ODBC32.dll
#include <windows.h>

SHORT SQLBindCol(
    void* StatementHandle,
    WORD ColumnNumber,
    SHORT TargetType,
    void* TargetValue,   // optional
    INT BufferLength,
    INT* StrLen_or_Ind   // optional
);
[DllImport("ODBC32.dll", ExactSpelling = true)]
static extern short SQLBindCol(
    IntPtr StatementHandle,   // void* in/out
    ushort ColumnNumber,   // WORD
    short TargetType,   // SHORT
    IntPtr TargetValue,   // void* optional, in/out
    int BufferLength,   // INT
    IntPtr StrLen_or_Ind   // INT* optional, in/out
);
<DllImport("ODBC32.dll", ExactSpelling:=True)>
Public Shared Function SQLBindCol(
    StatementHandle As IntPtr,   ' void* in/out
    ColumnNumber As UShort,   ' WORD
    TargetType As Short,   ' SHORT
    TargetValue As IntPtr,   ' void* optional, in/out
    BufferLength As Integer,   ' INT
    StrLen_or_Ind As IntPtr   ' INT* optional, in/out
) As Short
End Function
' StatementHandle : void* in/out
' ColumnNumber : WORD
' TargetType : SHORT
' TargetValue : void* optional, in/out
' BufferLength : INT
' StrLen_or_Ind : INT* optional, in/out
Declare PtrSafe Function SQLBindCol Lib "odbc32" ( _
    ByVal StatementHandle As LongPtr, _
    ByVal ColumnNumber As Integer, _
    ByVal TargetType As Integer, _
    ByVal TargetValue As LongPtr, _
    ByVal BufferLength As Long, _
    ByVal StrLen_or_Ind As LongPtr) As Integer
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SQLBindCol = ctypes.windll.odbc32.SQLBindCol
SQLBindCol.restype = ctypes.c_short
SQLBindCol.argtypes = [
    ctypes.POINTER(None),  # StatementHandle : void* in/out
    ctypes.c_ushort,  # ColumnNumber : WORD
    ctypes.c_short,  # TargetType : SHORT
    ctypes.POINTER(None),  # TargetValue : void* optional, in/out
    ctypes.c_int,  # BufferLength : INT
    ctypes.POINTER(ctypes.c_int),  # StrLen_or_Ind : INT* optional, in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('ODBC32.dll')
SQLBindCol = Fiddle::Function.new(
  lib['SQLBindCol'],
  [
    Fiddle::TYPE_VOIDP,  # StatementHandle : void* in/out
    -Fiddle::TYPE_SHORT,  # ColumnNumber : WORD
    Fiddle::TYPE_SHORT,  # TargetType : SHORT
    Fiddle::TYPE_VOIDP,  # TargetValue : void* optional, in/out
    Fiddle::TYPE_INT,  # BufferLength : INT
    Fiddle::TYPE_VOIDP,  # StrLen_or_Ind : INT* optional, in/out
  ],
  Fiddle::TYPE_SHORT)
#[link(name = "odbc32")]
extern "system" {
    fn SQLBindCol(
        StatementHandle: *mut (),  // void* in/out
        ColumnNumber: u16,  // WORD
        TargetType: i16,  // SHORT
        TargetValue: *mut (),  // void* optional, in/out
        BufferLength: i32,  // INT
        StrLen_or_Ind: *mut i32  // INT* optional, in/out
    ) -> i16;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("ODBC32.dll")]
public static extern short SQLBindCol(IntPtr StatementHandle, ushort ColumnNumber, short TargetType, IntPtr TargetValue, int BufferLength, IntPtr StrLen_or_Ind);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ODBC32_SQLBindCol' -Namespace Win32 -PassThru
# $api::SQLBindCol(StatementHandle, ColumnNumber, TargetType, TargetValue, BufferLength, StrLen_or_Ind)
#uselib "ODBC32.dll"
#func global SQLBindCol "SQLBindCol" sptr, sptr, sptr, sptr, sptr, sptr
; SQLBindCol StatementHandle, ColumnNumber, TargetType, TargetValue, BufferLength, varptr(StrLen_or_Ind)   ; 戻り値は stat
; StatementHandle : void* in/out -> "sptr"
; ColumnNumber : WORD -> "sptr"
; TargetType : SHORT -> "sptr"
; TargetValue : void* optional, in/out -> "sptr"
; BufferLength : INT -> "sptr"
; StrLen_or_Ind : INT* optional, in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "ODBC32.dll"
#cfunc global SQLBindCol "SQLBindCol" sptr, int, int, sptr, int, var
; res = SQLBindCol(StatementHandle, ColumnNumber, TargetType, TargetValue, BufferLength, StrLen_or_Ind)
; StatementHandle : void* in/out -> "sptr"
; ColumnNumber : WORD -> "int"
; TargetType : SHORT -> "int"
; TargetValue : void* optional, in/out -> "sptr"
; BufferLength : INT -> "int"
; StrLen_or_Ind : INT* optional, in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; SHORT SQLBindCol(void* StatementHandle, WORD ColumnNumber, SHORT TargetType, void* TargetValue, INT BufferLength, INT* StrLen_or_Ind)
#uselib "ODBC32.dll"
#cfunc global SQLBindCol "SQLBindCol" intptr, int, int, intptr, int, var
; res = SQLBindCol(StatementHandle, ColumnNumber, TargetType, TargetValue, BufferLength, StrLen_or_Ind)
; StatementHandle : void* in/out -> "intptr"
; ColumnNumber : WORD -> "int"
; TargetType : SHORT -> "int"
; TargetValue : void* optional, in/out -> "intptr"
; BufferLength : INT -> "int"
; StrLen_or_Ind : INT* optional, in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	odbc32 = windows.NewLazySystemDLL("ODBC32.dll")
	procSQLBindCol = odbc32.NewProc("SQLBindCol")
)

// StatementHandle (void* in/out), ColumnNumber (WORD), TargetType (SHORT), TargetValue (void* optional, in/out), BufferLength (INT), StrLen_or_Ind (INT* optional, in/out)
r1, _, err := procSQLBindCol.Call(
	uintptr(StatementHandle),
	uintptr(ColumnNumber),
	uintptr(TargetType),
	uintptr(TargetValue),
	uintptr(BufferLength),
	uintptr(StrLen_or_Ind),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // SHORT
function SQLBindCol(
  StatementHandle: Pointer;   // void* in/out
  ColumnNumber: Word;   // WORD
  TargetType: Smallint;   // SHORT
  TargetValue: Pointer;   // void* optional, in/out
  BufferLength: Integer;   // INT
  StrLen_or_Ind: Pointer   // INT* optional, in/out
): Smallint; stdcall;
  external 'ODBC32.dll' name 'SQLBindCol';
result := DllCall("ODBC32\SQLBindCol"
    , "Ptr", StatementHandle   ; void* in/out
    , "UShort", ColumnNumber   ; WORD
    , "Short", TargetType   ; SHORT
    , "Ptr", TargetValue   ; void* optional, in/out
    , "Int", BufferLength   ; INT
    , "Ptr", StrLen_or_Ind   ; INT* optional, in/out
    , "Short")   ; return: SHORT
●SQLBindCol(StatementHandle, ColumnNumber, TargetType, TargetValue, BufferLength, StrLen_or_Ind) = DLL("ODBC32.dll", "int SQLBindCol(void*, int, int, void*, int, void*)")
# 呼び出し: SQLBindCol(StatementHandle, ColumnNumber, TargetType, TargetValue, BufferLength, StrLen_or_Ind)
# StatementHandle : void* in/out -> "void*"
# ColumnNumber : WORD -> "int"
# TargetType : SHORT -> "int"
# TargetValue : void* optional, in/out -> "void*"
# BufferLength : INT -> "int"
# StrLen_or_Ind : INT* optional, in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。