ホーム › System.Search › SQLDescribeColW
SQLDescribeColW
関数結果セット列の名前や型などの属性を取得する(Unicode)。
シグネチャ
// ODBC32.dll (Unicode / -W)
#include <windows.h>
SHORT SQLDescribeColW(
void* hstmt,
WORD icol,
WORD* szColName, // optional
SHORT cchColNameMax,
SHORT* pcchColName, // optional
SHORT* pfSqlType, // optional
DWORD* pcbColDef, // optional
SHORT* pibScale, // optional
SHORT* pfNullable // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hstmt | void* | inout |
| icol | WORD | in |
| szColName | WORD* | outoptional |
| cchColNameMax | SHORT | in |
| pcchColName | SHORT* | outoptional |
| pfSqlType | SHORT* | outoptional |
| pcbColDef | DWORD* | outoptional |
| pibScale | SHORT* | outoptional |
| pfNullable | SHORT* | outoptional |
戻り値の型: SHORT
各言語での呼び出し定義
// ODBC32.dll (Unicode / -W)
#include <windows.h>
SHORT SQLDescribeColW(
void* hstmt,
WORD icol,
WORD* szColName, // optional
SHORT cchColNameMax,
SHORT* pcchColName, // optional
SHORT* pfSqlType, // optional
DWORD* pcbColDef, // optional
SHORT* pibScale, // optional
SHORT* pfNullable // optional
);[DllImport("ODBC32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern short SQLDescribeColW(
IntPtr hstmt, // void* in/out
ushort icol, // WORD
IntPtr szColName, // WORD* optional, out
short cchColNameMax, // SHORT
IntPtr pcchColName, // SHORT* optional, out
IntPtr pfSqlType, // SHORT* optional, out
IntPtr pcbColDef, // DWORD* optional, out
IntPtr pibScale, // SHORT* optional, out
IntPtr pfNullable // SHORT* optional, out
);<DllImport("ODBC32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function SQLDescribeColW(
hstmt As IntPtr, ' void* in/out
icol As UShort, ' WORD
szColName As IntPtr, ' WORD* optional, out
cchColNameMax As Short, ' SHORT
pcchColName As IntPtr, ' SHORT* optional, out
pfSqlType As IntPtr, ' SHORT* optional, out
pcbColDef 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
' icol : WORD
' szColName : WORD* optional, out
' cchColNameMax : SHORT
' pcchColName : SHORT* optional, out
' pfSqlType : SHORT* optional, out
' pcbColDef : DWORD* optional, out
' pibScale : SHORT* optional, out
' pfNullable : SHORT* optional, out
Declare PtrSafe Function SQLDescribeColW Lib "odbc32" ( _
ByVal hstmt As LongPtr, _
ByVal icol As Integer, _
ByVal szColName As LongPtr, _
ByVal cchColNameMax As Integer, _
ByVal pcchColName As LongPtr, _
ByVal pfSqlType As LongPtr, _
ByVal pcbColDef As LongPtr, _
ByVal pibScale As LongPtr, _
ByVal pfNullable As LongPtr) As Integer
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SQLDescribeColW = ctypes.windll.odbc32.SQLDescribeColW
SQLDescribeColW.restype = ctypes.c_short
SQLDescribeColW.argtypes = [
ctypes.POINTER(None), # hstmt : void* in/out
ctypes.c_ushort, # icol : WORD
ctypes.POINTER(ctypes.c_ushort), # szColName : WORD* optional, out
ctypes.c_short, # cchColNameMax : SHORT
ctypes.POINTER(ctypes.c_short), # pcchColName : SHORT* optional, out
ctypes.POINTER(ctypes.c_short), # pfSqlType : SHORT* optional, out
ctypes.POINTER(wintypes.DWORD), # pcbColDef : 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')
SQLDescribeColW = Fiddle::Function.new(
lib['SQLDescribeColW'],
[
Fiddle::TYPE_VOIDP, # hstmt : void* in/out
-Fiddle::TYPE_SHORT, # icol : WORD
Fiddle::TYPE_VOIDP, # szColName : WORD* optional, out
Fiddle::TYPE_SHORT, # cchColNameMax : SHORT
Fiddle::TYPE_VOIDP, # pcchColName : SHORT* optional, out
Fiddle::TYPE_VOIDP, # pfSqlType : SHORT* optional, out
Fiddle::TYPE_VOIDP, # pcbColDef : DWORD* optional, out
Fiddle::TYPE_VOIDP, # pibScale : SHORT* optional, out
Fiddle::TYPE_VOIDP, # pfNullable : SHORT* optional, out
],
Fiddle::TYPE_SHORT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "odbc32")]
extern "system" {
fn SQLDescribeColW(
hstmt: *mut (), // void* in/out
icol: u16, // WORD
szColName: *mut u16, // WORD* optional, out
cchColNameMax: i16, // SHORT
pcchColName: *mut i16, // SHORT* optional, out
pfSqlType: *mut i16, // SHORT* optional, out
pcbColDef: *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", CharSet = CharSet.Unicode)]
public static extern short SQLDescribeColW(IntPtr hstmt, ushort icol, IntPtr szColName, short cchColNameMax, IntPtr pcchColName, IntPtr pfSqlType, IntPtr pcbColDef, IntPtr pibScale, IntPtr pfNullable);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ODBC32_SQLDescribeColW' -Namespace Win32 -PassThru
# $api::SQLDescribeColW(hstmt, icol, szColName, cchColNameMax, pcchColName, pfSqlType, pcbColDef, pibScale, pfNullable)#uselib "ODBC32.dll"
#func global SQLDescribeColW "SQLDescribeColW" wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr
; SQLDescribeColW hstmt, icol, varptr(szColName), cchColNameMax, varptr(pcchColName), varptr(pfSqlType), varptr(pcbColDef), varptr(pibScale), varptr(pfNullable) ; 戻り値は stat
; hstmt : void* in/out -> "wptr"
; icol : WORD -> "wptr"
; szColName : WORD* optional, out -> "wptr"
; cchColNameMax : SHORT -> "wptr"
; pcchColName : SHORT* optional, out -> "wptr"
; pfSqlType : SHORT* optional, out -> "wptr"
; pcbColDef : DWORD* optional, out -> "wptr"
; pibScale : SHORT* optional, out -> "wptr"
; pfNullable : SHORT* optional, out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "ODBC32.dll" #cfunc global SQLDescribeColW "SQLDescribeColW" sptr, int, var, int, var, var, var, var, var ; res = SQLDescribeColW(hstmt, icol, szColName, cchColNameMax, pcchColName, pfSqlType, pcbColDef, pibScale, pfNullable) ; hstmt : void* in/out -> "sptr" ; icol : WORD -> "int" ; szColName : WORD* optional, out -> "var" ; cchColNameMax : SHORT -> "int" ; pcchColName : SHORT* optional, out -> "var" ; pfSqlType : SHORT* optional, out -> "var" ; pcbColDef : DWORD* optional, out -> "var" ; pibScale : SHORT* optional, out -> "var" ; pfNullable : SHORT* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ODBC32.dll" #cfunc global SQLDescribeColW "SQLDescribeColW" sptr, int, sptr, int, sptr, sptr, sptr, sptr, sptr ; res = SQLDescribeColW(hstmt, icol, varptr(szColName), cchColNameMax, varptr(pcchColName), varptr(pfSqlType), varptr(pcbColDef), varptr(pibScale), varptr(pfNullable)) ; hstmt : void* in/out -> "sptr" ; icol : WORD -> "int" ; szColName : WORD* optional, out -> "sptr" ; cchColNameMax : SHORT -> "int" ; pcchColName : SHORT* optional, out -> "sptr" ; pfSqlType : SHORT* optional, out -> "sptr" ; pcbColDef : DWORD* optional, out -> "sptr" ; pibScale : SHORT* optional, out -> "sptr" ; pfNullable : SHORT* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; SHORT SQLDescribeColW(void* hstmt, WORD icol, WORD* szColName, SHORT cchColNameMax, SHORT* pcchColName, SHORT* pfSqlType, DWORD* pcbColDef, SHORT* pibScale, SHORT* pfNullable) #uselib "ODBC32.dll" #cfunc global SQLDescribeColW "SQLDescribeColW" intptr, int, var, int, var, var, var, var, var ; res = SQLDescribeColW(hstmt, icol, szColName, cchColNameMax, pcchColName, pfSqlType, pcbColDef, pibScale, pfNullable) ; hstmt : void* in/out -> "intptr" ; icol : WORD -> "int" ; szColName : WORD* optional, out -> "var" ; cchColNameMax : SHORT -> "int" ; pcchColName : SHORT* optional, out -> "var" ; pfSqlType : SHORT* optional, out -> "var" ; pcbColDef : DWORD* optional, out -> "var" ; pibScale : SHORT* optional, out -> "var" ; pfNullable : SHORT* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; SHORT SQLDescribeColW(void* hstmt, WORD icol, WORD* szColName, SHORT cchColNameMax, SHORT* pcchColName, SHORT* pfSqlType, DWORD* pcbColDef, SHORT* pibScale, SHORT* pfNullable) #uselib "ODBC32.dll" #cfunc global SQLDescribeColW "SQLDescribeColW" intptr, int, intptr, int, intptr, intptr, intptr, intptr, intptr ; res = SQLDescribeColW(hstmt, icol, varptr(szColName), cchColNameMax, varptr(pcchColName), varptr(pfSqlType), varptr(pcbColDef), varptr(pibScale), varptr(pfNullable)) ; hstmt : void* in/out -> "intptr" ; icol : WORD -> "int" ; szColName : WORD* optional, out -> "intptr" ; cchColNameMax : SHORT -> "int" ; pcchColName : SHORT* optional, out -> "intptr" ; pfSqlType : SHORT* optional, out -> "intptr" ; pcbColDef : 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")
procSQLDescribeColW = odbc32.NewProc("SQLDescribeColW")
)
// hstmt (void* in/out), icol (WORD), szColName (WORD* optional, out), cchColNameMax (SHORT), pcchColName (SHORT* optional, out), pfSqlType (SHORT* optional, out), pcbColDef (DWORD* optional, out), pibScale (SHORT* optional, out), pfNullable (SHORT* optional, out)
r1, _, err := procSQLDescribeColW.Call(
uintptr(hstmt),
uintptr(icol),
uintptr(szColName),
uintptr(cchColNameMax),
uintptr(pcchColName),
uintptr(pfSqlType),
uintptr(pcbColDef),
uintptr(pibScale),
uintptr(pfNullable),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // SHORTfunction SQLDescribeColW(
hstmt: Pointer; // void* in/out
icol: Word; // WORD
szColName: Pointer; // WORD* optional, out
cchColNameMax: Smallint; // SHORT
pcchColName: Pointer; // SHORT* optional, out
pfSqlType: Pointer; // SHORT* optional, out
pcbColDef: Pointer; // DWORD* optional, out
pibScale: Pointer; // SHORT* optional, out
pfNullable: Pointer // SHORT* optional, out
): Smallint; stdcall;
external 'ODBC32.dll' name 'SQLDescribeColW';result := DllCall("ODBC32\SQLDescribeColW"
, "Ptr", hstmt ; void* in/out
, "UShort", icol ; WORD
, "Ptr", szColName ; WORD* optional, out
, "Short", cchColNameMax ; SHORT
, "Ptr", pcchColName ; SHORT* optional, out
, "Ptr", pfSqlType ; SHORT* optional, out
, "Ptr", pcbColDef ; DWORD* optional, out
, "Ptr", pibScale ; SHORT* optional, out
, "Ptr", pfNullable ; SHORT* optional, out
, "Short") ; return: SHORT●SQLDescribeColW(hstmt, icol, szColName, cchColNameMax, pcchColName, pfSqlType, pcbColDef, pibScale, pfNullable) = DLL("ODBC32.dll", "int SQLDescribeColW(void*, int, void*, int, void*, void*, void*, void*, void*)")
# 呼び出し: SQLDescribeColW(hstmt, icol, szColName, cchColNameMax, pcchColName, pfSqlType, pcbColDef, pibScale, pfNullable)
# hstmt : void* in/out -> "void*"
# icol : WORD -> "int"
# szColName : WORD* optional, out -> "void*"
# cchColNameMax : SHORT -> "int"
# pcchColName : SHORT* optional, out -> "void*"
# pfSqlType : SHORT* optional, out -> "void*"
# pcbColDef : DWORD* optional, out -> "void*"
# pibScale : SHORT* optional, out -> "void*"
# pfNullable : SHORT* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。