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

SQLSpecialColumns

関数
行を一意に識別する列や更新時変化列の情報を返す。
DLLODBC32.dll文字セットANSI (-A)呼出規約winapi

シグネチャ

// ODBC32.dll  (ANSI / -A)
#include <windows.h>

SHORT SQLSpecialColumns(
    void* StatementHandle,
    WORD IdentifierType,
    BYTE* CatalogName,   // optional
    SHORT NameLength1,
    BYTE* SchemaName,   // optional
    SHORT NameLength2,
    BYTE* TableName,   // optional
    SHORT NameLength3,
    WORD Scope,
    WORD Nullable
);

パラメーター

名前方向
StatementHandlevoid*inout
IdentifierTypeWORDin
CatalogNameBYTE*inoptional
NameLength1SHORTin
SchemaNameBYTE*inoptional
NameLength2SHORTin
TableNameBYTE*inoptional
NameLength3SHORTin
ScopeWORDin
NullableWORDin

戻り値の型: SHORT

各言語での呼び出し定義

// ODBC32.dll  (ANSI / -A)
#include <windows.h>

SHORT SQLSpecialColumns(
    void* StatementHandle,
    WORD IdentifierType,
    BYTE* CatalogName,   // optional
    SHORT NameLength1,
    BYTE* SchemaName,   // optional
    SHORT NameLength2,
    BYTE* TableName,   // optional
    SHORT NameLength3,
    WORD Scope,
    WORD Nullable
);
[DllImport("ODBC32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern short SQLSpecialColumns(
    IntPtr StatementHandle,   // void* in/out
    ushort IdentifierType,   // WORD
    IntPtr CatalogName,   // BYTE* optional
    short NameLength1,   // SHORT
    IntPtr SchemaName,   // BYTE* optional
    short NameLength2,   // SHORT
    IntPtr TableName,   // BYTE* optional
    short NameLength3,   // SHORT
    ushort Scope,   // WORD
    ushort Nullable   // WORD
);
<DllImport("ODBC32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function SQLSpecialColumns(
    StatementHandle As IntPtr,   ' void* in/out
    IdentifierType As UShort,   ' WORD
    CatalogName As IntPtr,   ' BYTE* optional
    NameLength1 As Short,   ' SHORT
    SchemaName As IntPtr,   ' BYTE* optional
    NameLength2 As Short,   ' SHORT
    TableName As IntPtr,   ' BYTE* optional
    NameLength3 As Short,   ' SHORT
    Scope As UShort,   ' WORD
    Nullable As UShort   ' WORD
) As Short
End Function
' StatementHandle : void* in/out
' IdentifierType : WORD
' CatalogName : BYTE* optional
' NameLength1 : SHORT
' SchemaName : BYTE* optional
' NameLength2 : SHORT
' TableName : BYTE* optional
' NameLength3 : SHORT
' Scope : WORD
' Nullable : WORD
Declare PtrSafe Function SQLSpecialColumns Lib "odbc32" ( _
    ByVal StatementHandle As LongPtr, _
    ByVal IdentifierType As Integer, _
    ByVal CatalogName As LongPtr, _
    ByVal NameLength1 As Integer, _
    ByVal SchemaName As LongPtr, _
    ByVal NameLength2 As Integer, _
    ByVal TableName As LongPtr, _
    ByVal NameLength3 As Integer, _
    ByVal Scope As Integer, _
    ByVal Nullable As Integer) As Integer
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SQLSpecialColumns = ctypes.windll.odbc32.SQLSpecialColumns
SQLSpecialColumns.restype = ctypes.c_short
SQLSpecialColumns.argtypes = [
    ctypes.POINTER(None),  # StatementHandle : void* in/out
    ctypes.c_ushort,  # IdentifierType : WORD
    ctypes.POINTER(ctypes.c_ubyte),  # CatalogName : BYTE* optional
    ctypes.c_short,  # NameLength1 : SHORT
    ctypes.POINTER(ctypes.c_ubyte),  # SchemaName : BYTE* optional
    ctypes.c_short,  # NameLength2 : SHORT
    ctypes.POINTER(ctypes.c_ubyte),  # TableName : BYTE* optional
    ctypes.c_short,  # NameLength3 : SHORT
    ctypes.c_ushort,  # Scope : WORD
    ctypes.c_ushort,  # Nullable : WORD
]
require 'fiddle'
require 'fiddle/import'

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

var (
	odbc32 = windows.NewLazySystemDLL("ODBC32.dll")
	procSQLSpecialColumns = odbc32.NewProc("SQLSpecialColumns")
)

// StatementHandle (void* in/out), IdentifierType (WORD), CatalogName (BYTE* optional), NameLength1 (SHORT), SchemaName (BYTE* optional), NameLength2 (SHORT), TableName (BYTE* optional), NameLength3 (SHORT), Scope (WORD), Nullable (WORD)
r1, _, err := procSQLSpecialColumns.Call(
	uintptr(StatementHandle),
	uintptr(IdentifierType),
	uintptr(CatalogName),
	uintptr(NameLength1),
	uintptr(SchemaName),
	uintptr(NameLength2),
	uintptr(TableName),
	uintptr(NameLength3),
	uintptr(Scope),
	uintptr(Nullable),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // SHORT
function SQLSpecialColumns(
  StatementHandle: Pointer;   // void* in/out
  IdentifierType: Word;   // WORD
  CatalogName: Pointer;   // BYTE* optional
  NameLength1: Smallint;   // SHORT
  SchemaName: Pointer;   // BYTE* optional
  NameLength2: Smallint;   // SHORT
  TableName: Pointer;   // BYTE* optional
  NameLength3: Smallint;   // SHORT
  Scope: Word;   // WORD
  Nullable: Word   // WORD
): Smallint; stdcall;
  external 'ODBC32.dll' name 'SQLSpecialColumns';
result := DllCall("ODBC32\SQLSpecialColumns"
    , "Ptr", StatementHandle   ; void* in/out
    , "UShort", IdentifierType   ; WORD
    , "Ptr", CatalogName   ; BYTE* optional
    , "Short", NameLength1   ; SHORT
    , "Ptr", SchemaName   ; BYTE* optional
    , "Short", NameLength2   ; SHORT
    , "Ptr", TableName   ; BYTE* optional
    , "Short", NameLength3   ; SHORT
    , "UShort", Scope   ; WORD
    , "UShort", Nullable   ; WORD
    , "Short")   ; return: SHORT
●SQLSpecialColumns(StatementHandle, IdentifierType, CatalogName, NameLength1, SchemaName, NameLength2, TableName, NameLength3, Scope, Nullable) = DLL("ODBC32.dll", "int SQLSpecialColumns(void*, int, void*, int, void*, int, void*, int, int, int)")
# 呼び出し: SQLSpecialColumns(StatementHandle, IdentifierType, CatalogName, NameLength1, SchemaName, NameLength2, TableName, NameLength3, Scope, Nullable)
# StatementHandle : void* in/out -> "void*"
# IdentifierType : WORD -> "int"
# CatalogName : BYTE* optional -> "void*"
# NameLength1 : SHORT -> "int"
# SchemaName : BYTE* optional -> "void*"
# NameLength2 : SHORT -> "int"
# TableName : BYTE* optional -> "void*"
# NameLength3 : SHORT -> "int"
# Scope : WORD -> "int"
# Nullable : WORD -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。