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取得する列種別。SQL_BEST_ROWID(一意識別)かSQL_ROWVER(更新検出)。
CatalogNameBYTE*inoptionalカタログ(データベース)名。ANSI文字列。NULL可。
NameLength1SHORTinCatalogNameの文字数。SQL_NTSでNUL終端を示す。
SchemaNameBYTE*inoptionalスキーマ名。ANSI文字列。NULL可。
NameLength2SHORTinSchemaNameの文字数。SQL_NTSでNUL終端を示す。
TableNameBYTE*inoptionalテーブル名。ANSI文字列。NULL不可。
NameLength3SHORTinTableNameの文字数。SQL_NTSでNUL終端を示す。
ScopeWORDin行ID有効範囲。SQL_SCOPE_CURROW/TRANSACTION/SESSIONを指定する。
NullableWORDinNULL許容列を含めるか。SQL_NO_NULLS/SQL_NULLABLEを指定する。

戻り値の型: 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)。
const std = @import("std");

extern "odbc32" fn SQLSpecialColumns(
    StatementHandle: ?*anyopaque, // void* in/out
    IdentifierType: u16, // WORD
    CatalogName: [*c]u8, // BYTE* optional
    NameLength1: i16, // SHORT
    SchemaName: [*c]u8, // BYTE* optional
    NameLength2: i16, // SHORT
    TableName: [*c]u8, // BYTE* optional
    NameLength3: i16, // SHORT
    Scope: u16, // WORD
    Nullable: u16 // WORD
) callconv(std.os.windows.WINAPI) i16;
proc SQLSpecialColumns(
    StatementHandle: pointer,  # void* in/out
    IdentifierType: uint16,  # WORD
    CatalogName: ptr uint8,  # BYTE* optional
    NameLength1: int16,  # SHORT
    SchemaName: ptr uint8,  # BYTE* optional
    NameLength2: int16,  # SHORT
    TableName: ptr uint8,  # BYTE* optional
    NameLength3: int16,  # SHORT
    Scope: uint16,  # WORD
    Nullable: uint16  # WORD
): int16 {.importc: "SQLSpecialColumns", stdcall, dynlib: "ODBC32.dll".}
pragma(lib, "odbc32");
extern(Windows)
short SQLSpecialColumns(
    void* StatementHandle,   // void* in/out
    ushort IdentifierType,   // WORD
    ubyte* CatalogName,   // BYTE* optional
    short NameLength1,   // SHORT
    ubyte* SchemaName,   // BYTE* optional
    short NameLength2,   // SHORT
    ubyte* TableName,   // BYTE* optional
    short NameLength3,   // SHORT
    ushort Scope,   // WORD
    ushort Nullable   // WORD
);
ccall((:SQLSpecialColumns, "ODBC32.dll"), stdcall, Int16,
      (Ptr{Cvoid}, UInt16, Ptr{UInt8}, Int16, Ptr{UInt8}, Int16, Ptr{UInt8}, Int16, UInt16, UInt16),
      StatementHandle, IdentifierType, CatalogName, NameLength1, SchemaName, NameLength2, TableName, NameLength3, Scope, Nullable)
# StatementHandle : void* in/out -> Ptr{Cvoid}
# IdentifierType : WORD -> UInt16
# CatalogName : BYTE* optional -> Ptr{UInt8}
# NameLength1 : SHORT -> Int16
# SchemaName : BYTE* optional -> Ptr{UInt8}
# NameLength2 : SHORT -> Int16
# TableName : BYTE* optional -> Ptr{UInt8}
# NameLength3 : SHORT -> Int16
# Scope : WORD -> UInt16
# Nullable : WORD -> UInt16
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int16_t SQLSpecialColumns(
    void* StatementHandle,
    uint16_t IdentifierType,
    uint8_t* CatalogName,
    int16_t NameLength1,
    uint8_t* SchemaName,
    int16_t NameLength2,
    uint8_t* TableName,
    int16_t NameLength3,
    uint16_t Scope,
    uint16_t Nullable);
]]
local odbc32 = ffi.load("odbc32")
-- odbc32.SQLSpecialColumns(StatementHandle, IdentifierType, CatalogName, NameLength1, SchemaName, NameLength2, TableName, NameLength3, Scope, Nullable)
-- 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
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('ODBC32.dll');
const SQLSpecialColumns = lib.func('__stdcall', 'SQLSpecialColumns', 'int16_t', ['void *', 'uint16_t', 'uint8_t *', 'int16_t', 'uint8_t *', 'int16_t', 'uint8_t *', 'int16_t', 'uint16_t', 'uint16_t']);
// SQLSpecialColumns(StatementHandle, IdentifierType, CatalogName, NameLength1, SchemaName, NameLength2, TableName, NameLength3, Scope, Nullable)
// StatementHandle : void* in/out -> 'void *'
// IdentifierType : WORD -> 'uint16_t'
// CatalogName : BYTE* optional -> 'uint8_t *'
// NameLength1 : SHORT -> 'int16_t'
// SchemaName : BYTE* optional -> 'uint8_t *'
// NameLength2 : SHORT -> 'int16_t'
// TableName : BYTE* optional -> 'uint8_t *'
// NameLength3 : SHORT -> 'int16_t'
// Scope : WORD -> 'uint16_t'
// Nullable : WORD -> 'uint16_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("ODBC32.dll", {
  SQLSpecialColumns: { parameters: ["pointer", "u16", "pointer", "i16", "pointer", "i16", "pointer", "i16", "u16", "u16"], result: "i16" },
});
// lib.symbols.SQLSpecialColumns(StatementHandle, IdentifierType, CatalogName, NameLength1, SchemaName, NameLength2, TableName, NameLength3, Scope, Nullable)
// StatementHandle : void* in/out -> "pointer"
// IdentifierType : WORD -> "u16"
// CatalogName : BYTE* optional -> "pointer"
// NameLength1 : SHORT -> "i16"
// SchemaName : BYTE* optional -> "pointer"
// NameLength2 : SHORT -> "i16"
// TableName : BYTE* optional -> "pointer"
// NameLength3 : SHORT -> "i16"
// Scope : WORD -> "u16"
// Nullable : WORD -> "u16"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int16_t SQLSpecialColumns(
    void* StatementHandle,
    uint16_t IdentifierType,
    uint8_t* CatalogName,
    int16_t NameLength1,
    uint8_t* SchemaName,
    int16_t NameLength2,
    uint8_t* TableName,
    int16_t NameLength3,
    uint16_t Scope,
    uint16_t Nullable);
C, "ODBC32.dll");
// $ffi->SQLSpecialColumns(StatementHandle, IdentifierType, CatalogName, NameLength1, SchemaName, NameLength2, TableName, NameLength3, Scope, Nullable);
// 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
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface Odbc32 extends StdCallLibrary {
    Odbc32 INSTANCE = Native.load("odbc32", Odbc32.class, W32APIOptions.ASCII_OPTIONS);
    short SQLSpecialColumns(
        Pointer StatementHandle,   // void* in/out
        short IdentifierType,   // WORD
        byte[] CatalogName,   // BYTE* optional
        short NameLength1,   // SHORT
        byte[] SchemaName,   // BYTE* optional
        short NameLength2,   // SHORT
        byte[] TableName,   // BYTE* optional
        short NameLength3,   // SHORT
        short Scope,   // WORD
        short Nullable   // WORD
    );
}
@[Link("odbc32")]
lib LibODBC32
  fun SQLSpecialColumns = SQLSpecialColumns(
    StatementHandle : Void*,   # void* in/out
    IdentifierType : UInt16,   # WORD
    CatalogName : UInt8*,   # BYTE* optional
    NameLength1 : Int16,   # SHORT
    SchemaName : UInt8*,   # BYTE* optional
    NameLength2 : Int16,   # SHORT
    TableName : UInt8*,   # BYTE* optional
    NameLength3 : Int16,   # SHORT
    Scope : UInt16,   # WORD
    Nullable : UInt16   # WORD
  ) : Int16
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef SQLSpecialColumnsNative = Int16 Function(Pointer<Void>, Uint16, Pointer<Uint8>, Int16, Pointer<Uint8>, Int16, Pointer<Uint8>, Int16, Uint16, Uint16);
typedef SQLSpecialColumnsDart = int Function(Pointer<Void>, int, Pointer<Uint8>, int, Pointer<Uint8>, int, Pointer<Uint8>, int, int, int);
final SQLSpecialColumns = DynamicLibrary.open('ODBC32.dll')
    .lookupFunction<SQLSpecialColumnsNative, SQLSpecialColumnsDart>('SQLSpecialColumns');
// StatementHandle : void* in/out -> Pointer<Void>
// IdentifierType : WORD -> Uint16
// CatalogName : BYTE* optional -> Pointer<Uint8>
// NameLength1 : SHORT -> Int16
// SchemaName : BYTE* optional -> Pointer<Uint8>
// NameLength2 : SHORT -> Int16
// TableName : BYTE* optional -> Pointer<Uint8>
// NameLength3 : SHORT -> Int16
// Scope : WORD -> Uint16
// Nullable : WORD -> Uint16
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
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';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "SQLSpecialColumns"
  c_SQLSpecialColumns :: Ptr () -> Word16 -> Ptr Word8 -> Int16 -> Ptr Word8 -> Int16 -> Ptr Word8 -> Int16 -> Word16 -> Word16 -> IO Int16
-- StatementHandle : void* in/out -> Ptr ()
-- IdentifierType : WORD -> Word16
-- CatalogName : BYTE* optional -> Ptr Word8
-- NameLength1 : SHORT -> Int16
-- SchemaName : BYTE* optional -> Ptr Word8
-- NameLength2 : SHORT -> Int16
-- TableName : BYTE* optional -> Ptr Word8
-- NameLength3 : SHORT -> Int16
-- Scope : WORD -> Word16
-- Nullable : WORD -> Word16
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let sqlspecialcolumns =
  foreign "SQLSpecialColumns"
    ((ptr void) @-> uint16_t @-> (ptr uint8_t) @-> int16_t @-> (ptr uint8_t) @-> int16_t @-> (ptr uint8_t) @-> int16_t @-> uint16_t @-> uint16_t @-> returning int16_t)
(* StatementHandle : void* in/out -> (ptr void) *)
(* IdentifierType : WORD -> uint16_t *)
(* CatalogName : BYTE* optional -> (ptr uint8_t) *)
(* NameLength1 : SHORT -> int16_t *)
(* SchemaName : BYTE* optional -> (ptr uint8_t) *)
(* NameLength2 : SHORT -> int16_t *)
(* TableName : BYTE* optional -> (ptr uint8_t) *)
(* NameLength3 : SHORT -> int16_t *)
(* Scope : WORD -> uint16_t *)
(* Nullable : WORD -> uint16_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library odbc32 (t "ODBC32.dll"))
(cffi:use-foreign-library odbc32)

(cffi:defcfun ("SQLSpecialColumns" sqlspecial-columns :convention :stdcall) :int16
  (statement-handle :pointer)   ; void* in/out
  (identifier-type :uint16)   ; WORD
  (catalog-name :pointer)   ; BYTE* optional
  (name-length1 :int16)   ; SHORT
  (schema-name :pointer)   ; BYTE* optional
  (name-length2 :int16)   ; SHORT
  (table-name :pointer)   ; BYTE* optional
  (name-length3 :int16)   ; SHORT
  (scope :uint16)   ; WORD
  (nullable :uint16))   ; WORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $SQLSpecialColumns = Win32::API::More->new('ODBC32',
    'short SQLSpecialColumns(LPVOID StatementHandle, WORD IdentifierType, LPVOID CatalogName, short NameLength1, LPVOID SchemaName, short NameLength2, LPVOID TableName, short NameLength3, WORD Scope, WORD Nullable)');
# my $ret = $SQLSpecialColumns->Call($StatementHandle, $IdentifierType, $CatalogName, $NameLength1, $SchemaName, $NameLength2, $TableName, $NameLength3, $Scope, $Nullable);
# StatementHandle : void* in/out -> LPVOID
# IdentifierType : WORD -> WORD
# CatalogName : BYTE* optional -> LPVOID
# NameLength1 : SHORT -> short
# SchemaName : BYTE* optional -> LPVOID
# NameLength2 : SHORT -> short
# TableName : BYTE* optional -> LPVOID
# NameLength3 : SHORT -> short
# Scope : WORD -> WORD
# Nullable : WORD -> WORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

文字セット違い