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