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