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

SQLColumnPrivilegesA

関数
テーブル列に対するアクセス権限の一覧を取得する。
DLLODBC32.dll文字セットANSI (-A)呼出規約winapi

シグネチャ

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

SHORT SQLColumnPrivilegesA(
    void* hstmt,
    BYTE* szCatalogName,   // optional
    SHORT cbCatalogName,
    BYTE* szSchemaName,   // optional
    SHORT cbSchemaName,
    BYTE* szTableName,   // optional
    SHORT cbTableName,
    BYTE* szColumnName,   // optional
    SHORT cbColumnName
);

パラメーター

名前方向説明
hstmtvoid*inoutODBCのステートメントハンドル。列権限の結果セットを返す。
szCatalogNameBYTE*inoptional検索対象のカタログ名。NULL指定可。
cbCatalogNameSHORTinszCatalogNameのバイト数。SQL_NTSでNUL終端とみなす。
szSchemaNameBYTE*inoptional検索対象のスキーマ名。NULL指定可。
cbSchemaNameSHORTinszSchemaNameのバイト数。SQL_NTSでNUL終端とみなす。
szTableNameBYTE*inoptional検索対象のテーブル名。
cbTableNameSHORTinszTableNameのバイト数。SQL_NTSでNUL終端とみなす。
szColumnNameBYTE*inoptional検索対象の列名。パターンで絞り込み可能。
cbColumnNameSHORTinszColumnNameのバイト数。SQL_NTSでNUL終端とみなす。

戻り値の型: SHORT

各言語での呼び出し定義

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

SHORT SQLColumnPrivilegesA(
    void* hstmt,
    BYTE* szCatalogName,   // optional
    SHORT cbCatalogName,
    BYTE* szSchemaName,   // optional
    SHORT cbSchemaName,
    BYTE* szTableName,   // optional
    SHORT cbTableName,
    BYTE* szColumnName,   // optional
    SHORT cbColumnName
);
[DllImport("ODBC32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern short SQLColumnPrivilegesA(
    IntPtr hstmt,   // void* in/out
    IntPtr szCatalogName,   // BYTE* optional
    short cbCatalogName,   // SHORT
    IntPtr szSchemaName,   // BYTE* optional
    short cbSchemaName,   // SHORT
    IntPtr szTableName,   // BYTE* optional
    short cbTableName,   // SHORT
    IntPtr szColumnName,   // BYTE* optional
    short cbColumnName   // SHORT
);
<DllImport("ODBC32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function SQLColumnPrivilegesA(
    hstmt As IntPtr,   ' void* in/out
    szCatalogName As IntPtr,   ' BYTE* optional
    cbCatalogName As Short,   ' SHORT
    szSchemaName As IntPtr,   ' BYTE* optional
    cbSchemaName As Short,   ' SHORT
    szTableName As IntPtr,   ' BYTE* optional
    cbTableName As Short,   ' SHORT
    szColumnName As IntPtr,   ' BYTE* optional
    cbColumnName As Short   ' SHORT
) As Short
End Function
' hstmt : void* in/out
' szCatalogName : BYTE* optional
' cbCatalogName : SHORT
' szSchemaName : BYTE* optional
' cbSchemaName : SHORT
' szTableName : BYTE* optional
' cbTableName : SHORT
' szColumnName : BYTE* optional
' cbColumnName : SHORT
Declare PtrSafe Function SQLColumnPrivilegesA Lib "odbc32" ( _
    ByVal hstmt As LongPtr, _
    ByVal szCatalogName As LongPtr, _
    ByVal cbCatalogName As Integer, _
    ByVal szSchemaName As LongPtr, _
    ByVal cbSchemaName As Integer, _
    ByVal szTableName As LongPtr, _
    ByVal cbTableName As Integer, _
    ByVal szColumnName As LongPtr, _
    ByVal cbColumnName As Integer) As Integer
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SQLColumnPrivilegesA = ctypes.windll.odbc32.SQLColumnPrivilegesA
SQLColumnPrivilegesA.restype = ctypes.c_short
SQLColumnPrivilegesA.argtypes = [
    ctypes.POINTER(None),  # hstmt : void* in/out
    ctypes.POINTER(ctypes.c_ubyte),  # szCatalogName : BYTE* optional
    ctypes.c_short,  # cbCatalogName : SHORT
    ctypes.POINTER(ctypes.c_ubyte),  # szSchemaName : BYTE* optional
    ctypes.c_short,  # cbSchemaName : SHORT
    ctypes.POINTER(ctypes.c_ubyte),  # szTableName : BYTE* optional
    ctypes.c_short,  # cbTableName : SHORT
    ctypes.POINTER(ctypes.c_ubyte),  # szColumnName : BYTE* optional
    ctypes.c_short,  # cbColumnName : SHORT
]
require 'fiddle'
require 'fiddle/import'

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

var (
	odbc32 = windows.NewLazySystemDLL("ODBC32.dll")
	procSQLColumnPrivilegesA = odbc32.NewProc("SQLColumnPrivilegesA")
)

// hstmt (void* in/out), szCatalogName (BYTE* optional), cbCatalogName (SHORT), szSchemaName (BYTE* optional), cbSchemaName (SHORT), szTableName (BYTE* optional), cbTableName (SHORT), szColumnName (BYTE* optional), cbColumnName (SHORT)
r1, _, err := procSQLColumnPrivilegesA.Call(
	uintptr(hstmt),
	uintptr(szCatalogName),
	uintptr(cbCatalogName),
	uintptr(szSchemaName),
	uintptr(cbSchemaName),
	uintptr(szTableName),
	uintptr(cbTableName),
	uintptr(szColumnName),
	uintptr(cbColumnName),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // SHORT
function SQLColumnPrivilegesA(
  hstmt: Pointer;   // void* in/out
  szCatalogName: Pointer;   // BYTE* optional
  cbCatalogName: Smallint;   // SHORT
  szSchemaName: Pointer;   // BYTE* optional
  cbSchemaName: Smallint;   // SHORT
  szTableName: Pointer;   // BYTE* optional
  cbTableName: Smallint;   // SHORT
  szColumnName: Pointer;   // BYTE* optional
  cbColumnName: Smallint   // SHORT
): Smallint; stdcall;
  external 'ODBC32.dll' name 'SQLColumnPrivilegesA';
result := DllCall("ODBC32\SQLColumnPrivilegesA"
    , "Ptr", hstmt   ; void* in/out
    , "Ptr", szCatalogName   ; BYTE* optional
    , "Short", cbCatalogName   ; SHORT
    , "Ptr", szSchemaName   ; BYTE* optional
    , "Short", cbSchemaName   ; SHORT
    , "Ptr", szTableName   ; BYTE* optional
    , "Short", cbTableName   ; SHORT
    , "Ptr", szColumnName   ; BYTE* optional
    , "Short", cbColumnName   ; SHORT
    , "Short")   ; return: SHORT
●SQLColumnPrivilegesA(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, szTableName, cbTableName, szColumnName, cbColumnName) = DLL("ODBC32.dll", "int SQLColumnPrivilegesA(void*, void*, int, void*, int, void*, int, void*, int)")
# 呼び出し: SQLColumnPrivilegesA(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, szTableName, cbTableName, szColumnName, cbColumnName)
# hstmt : void* in/out -> "void*"
# szCatalogName : BYTE* optional -> "void*"
# cbCatalogName : SHORT -> "int"
# szSchemaName : BYTE* optional -> "void*"
# cbSchemaName : SHORT -> "int"
# szTableName : BYTE* optional -> "void*"
# cbTableName : SHORT -> "int"
# szColumnName : BYTE* optional -> "void*"
# cbColumnName : SHORT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "odbc32" fn SQLColumnPrivilegesA(
    hstmt: ?*anyopaque, // void* in/out
    szCatalogName: [*c]u8, // BYTE* optional
    cbCatalogName: i16, // SHORT
    szSchemaName: [*c]u8, // BYTE* optional
    cbSchemaName: i16, // SHORT
    szTableName: [*c]u8, // BYTE* optional
    cbTableName: i16, // SHORT
    szColumnName: [*c]u8, // BYTE* optional
    cbColumnName: i16 // SHORT
) callconv(std.os.windows.WINAPI) i16;
proc SQLColumnPrivilegesA(
    hstmt: pointer,  # void* in/out
    szCatalogName: ptr uint8,  # BYTE* optional
    cbCatalogName: int16,  # SHORT
    szSchemaName: ptr uint8,  # BYTE* optional
    cbSchemaName: int16,  # SHORT
    szTableName: ptr uint8,  # BYTE* optional
    cbTableName: int16,  # SHORT
    szColumnName: ptr uint8,  # BYTE* optional
    cbColumnName: int16  # SHORT
): int16 {.importc: "SQLColumnPrivilegesA", stdcall, dynlib: "ODBC32.dll".}
pragma(lib, "odbc32");
extern(Windows)
short SQLColumnPrivilegesA(
    void* hstmt,   // void* in/out
    ubyte* szCatalogName,   // BYTE* optional
    short cbCatalogName,   // SHORT
    ubyte* szSchemaName,   // BYTE* optional
    short cbSchemaName,   // SHORT
    ubyte* szTableName,   // BYTE* optional
    short cbTableName,   // SHORT
    ubyte* szColumnName,   // BYTE* optional
    short cbColumnName   // SHORT
);
ccall((:SQLColumnPrivilegesA, "ODBC32.dll"), stdcall, Int16,
      (Ptr{Cvoid}, Ptr{UInt8}, Int16, Ptr{UInt8}, Int16, Ptr{UInt8}, Int16, Ptr{UInt8}, Int16),
      hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, szTableName, cbTableName, szColumnName, cbColumnName)
# hstmt : void* in/out -> Ptr{Cvoid}
# szCatalogName : BYTE* optional -> Ptr{UInt8}
# cbCatalogName : SHORT -> Int16
# szSchemaName : BYTE* optional -> Ptr{UInt8}
# cbSchemaName : SHORT -> Int16
# szTableName : BYTE* optional -> Ptr{UInt8}
# cbTableName : SHORT -> Int16
# szColumnName : BYTE* optional -> Ptr{UInt8}
# cbColumnName : SHORT -> Int16
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int16_t SQLColumnPrivilegesA(
    void* hstmt,
    uint8_t* szCatalogName,
    int16_t cbCatalogName,
    uint8_t* szSchemaName,
    int16_t cbSchemaName,
    uint8_t* szTableName,
    int16_t cbTableName,
    uint8_t* szColumnName,
    int16_t cbColumnName);
]]
local odbc32 = ffi.load("odbc32")
-- odbc32.SQLColumnPrivilegesA(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, szTableName, cbTableName, szColumnName, cbColumnName)
-- hstmt : void* in/out
-- szCatalogName : BYTE* optional
-- cbCatalogName : SHORT
-- szSchemaName : BYTE* optional
-- cbSchemaName : SHORT
-- szTableName : BYTE* optional
-- cbTableName : SHORT
-- szColumnName : BYTE* optional
-- cbColumnName : SHORT
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('ODBC32.dll');
const SQLColumnPrivilegesA = lib.func('__stdcall', 'SQLColumnPrivilegesA', 'int16_t', ['void *', 'uint8_t *', 'int16_t', 'uint8_t *', 'int16_t', 'uint8_t *', 'int16_t', 'uint8_t *', 'int16_t']);
// SQLColumnPrivilegesA(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, szTableName, cbTableName, szColumnName, cbColumnName)
// hstmt : void* in/out -> 'void *'
// szCatalogName : BYTE* optional -> 'uint8_t *'
// cbCatalogName : SHORT -> 'int16_t'
// szSchemaName : BYTE* optional -> 'uint8_t *'
// cbSchemaName : SHORT -> 'int16_t'
// szTableName : BYTE* optional -> 'uint8_t *'
// cbTableName : SHORT -> 'int16_t'
// szColumnName : BYTE* optional -> 'uint8_t *'
// cbColumnName : SHORT -> 'int16_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("ODBC32.dll", {
  SQLColumnPrivilegesA: { parameters: ["pointer", "pointer", "i16", "pointer", "i16", "pointer", "i16", "pointer", "i16"], result: "i16" },
});
// lib.symbols.SQLColumnPrivilegesA(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, szTableName, cbTableName, szColumnName, cbColumnName)
// hstmt : void* in/out -> "pointer"
// szCatalogName : BYTE* optional -> "pointer"
// cbCatalogName : SHORT -> "i16"
// szSchemaName : BYTE* optional -> "pointer"
// cbSchemaName : SHORT -> "i16"
// szTableName : BYTE* optional -> "pointer"
// cbTableName : SHORT -> "i16"
// szColumnName : BYTE* optional -> "pointer"
// cbColumnName : SHORT -> "i16"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int16_t SQLColumnPrivilegesA(
    void* hstmt,
    uint8_t* szCatalogName,
    int16_t cbCatalogName,
    uint8_t* szSchemaName,
    int16_t cbSchemaName,
    uint8_t* szTableName,
    int16_t cbTableName,
    uint8_t* szColumnName,
    int16_t cbColumnName);
C, "ODBC32.dll");
// $ffi->SQLColumnPrivilegesA(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, szTableName, cbTableName, szColumnName, cbColumnName);
// hstmt : void* in/out
// szCatalogName : BYTE* optional
// cbCatalogName : SHORT
// szSchemaName : BYTE* optional
// cbSchemaName : SHORT
// szTableName : BYTE* optional
// cbTableName : SHORT
// szColumnName : BYTE* optional
// cbColumnName : SHORT
// 構造体/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 SQLColumnPrivilegesA(
        Pointer hstmt,   // void* in/out
        byte[] szCatalogName,   // BYTE* optional
        short cbCatalogName,   // SHORT
        byte[] szSchemaName,   // BYTE* optional
        short cbSchemaName,   // SHORT
        byte[] szTableName,   // BYTE* optional
        short cbTableName,   // SHORT
        byte[] szColumnName,   // BYTE* optional
        short cbColumnName   // SHORT
    );
}
@[Link("odbc32")]
lib LibODBC32
  fun SQLColumnPrivilegesA = SQLColumnPrivilegesA(
    hstmt : Void*,   # void* in/out
    szCatalogName : UInt8*,   # BYTE* optional
    cbCatalogName : Int16,   # SHORT
    szSchemaName : UInt8*,   # BYTE* optional
    cbSchemaName : Int16,   # SHORT
    szTableName : UInt8*,   # BYTE* optional
    cbTableName : Int16,   # SHORT
    szColumnName : UInt8*,   # BYTE* optional
    cbColumnName : Int16   # SHORT
  ) : Int16
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef SQLColumnPrivilegesANative = Int16 Function(Pointer<Void>, Pointer<Uint8>, Int16, Pointer<Uint8>, Int16, Pointer<Uint8>, Int16, Pointer<Uint8>, Int16);
typedef SQLColumnPrivilegesADart = int Function(Pointer<Void>, Pointer<Uint8>, int, Pointer<Uint8>, int, Pointer<Uint8>, int, Pointer<Uint8>, int);
final SQLColumnPrivilegesA = DynamicLibrary.open('ODBC32.dll')
    .lookupFunction<SQLColumnPrivilegesANative, SQLColumnPrivilegesADart>('SQLColumnPrivilegesA');
// hstmt : void* in/out -> Pointer<Void>
// szCatalogName : BYTE* optional -> Pointer<Uint8>
// cbCatalogName : SHORT -> Int16
// szSchemaName : BYTE* optional -> Pointer<Uint8>
// cbSchemaName : SHORT -> Int16
// szTableName : BYTE* optional -> Pointer<Uint8>
// cbTableName : SHORT -> Int16
// szColumnName : BYTE* optional -> Pointer<Uint8>
// cbColumnName : SHORT -> Int16
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function SQLColumnPrivilegesA(
  hstmt: Pointer;   // void* in/out
  szCatalogName: Pointer;   // BYTE* optional
  cbCatalogName: Smallint;   // SHORT
  szSchemaName: Pointer;   // BYTE* optional
  cbSchemaName: Smallint;   // SHORT
  szTableName: Pointer;   // BYTE* optional
  cbTableName: Smallint;   // SHORT
  szColumnName: Pointer;   // BYTE* optional
  cbColumnName: Smallint   // SHORT
): Smallint; stdcall;
  external 'ODBC32.dll' name 'SQLColumnPrivilegesA';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "SQLColumnPrivilegesA"
  c_SQLColumnPrivilegesA :: Ptr () -> Ptr Word8 -> Int16 -> Ptr Word8 -> Int16 -> Ptr Word8 -> Int16 -> Ptr Word8 -> Int16 -> IO Int16
-- hstmt : void* in/out -> Ptr ()
-- szCatalogName : BYTE* optional -> Ptr Word8
-- cbCatalogName : SHORT -> Int16
-- szSchemaName : BYTE* optional -> Ptr Word8
-- cbSchemaName : SHORT -> Int16
-- szTableName : BYTE* optional -> Ptr Word8
-- cbTableName : SHORT -> Int16
-- szColumnName : BYTE* optional -> Ptr Word8
-- cbColumnName : SHORT -> Int16
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let sqlcolumnprivilegesa =
  foreign "SQLColumnPrivilegesA"
    ((ptr void) @-> (ptr uint8_t) @-> int16_t @-> (ptr uint8_t) @-> int16_t @-> (ptr uint8_t) @-> int16_t @-> (ptr uint8_t) @-> int16_t @-> returning int16_t)
(* hstmt : void* in/out -> (ptr void) *)
(* szCatalogName : BYTE* optional -> (ptr uint8_t) *)
(* cbCatalogName : SHORT -> int16_t *)
(* szSchemaName : BYTE* optional -> (ptr uint8_t) *)
(* cbSchemaName : SHORT -> int16_t *)
(* szTableName : BYTE* optional -> (ptr uint8_t) *)
(* cbTableName : SHORT -> int16_t *)
(* szColumnName : BYTE* optional -> (ptr uint8_t) *)
(* cbColumnName : SHORT -> int16_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library odbc32 (t "ODBC32.dll"))
(cffi:use-foreign-library odbc32)

(cffi:defcfun ("SQLColumnPrivilegesA" sqlcolumn-privileges-a :convention :stdcall) :int16
  (hstmt :pointer)   ; void* in/out
  (sz-catalog-name :pointer)   ; BYTE* optional
  (cb-catalog-name :int16)   ; SHORT
  (sz-schema-name :pointer)   ; BYTE* optional
  (cb-schema-name :int16)   ; SHORT
  (sz-table-name :pointer)   ; BYTE* optional
  (cb-table-name :int16)   ; SHORT
  (sz-column-name :pointer)   ; BYTE* optional
  (cb-column-name :int16))   ; SHORT
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $SQLColumnPrivilegesA = Win32::API::More->new('ODBC32',
    'short SQLColumnPrivilegesA(LPVOID hstmt, LPVOID szCatalogName, short cbCatalogName, LPVOID szSchemaName, short cbSchemaName, LPVOID szTableName, short cbTableName, LPVOID szColumnName, short cbColumnName)');
# my $ret = $SQLColumnPrivilegesA->Call($hstmt, $szCatalogName, $cbCatalogName, $szSchemaName, $cbSchemaName, $szTableName, $cbTableName, $szColumnName, $cbColumnName);
# hstmt : void* in/out -> LPVOID
# szCatalogName : BYTE* optional -> LPVOID
# cbCatalogName : SHORT -> short
# szSchemaName : BYTE* optional -> LPVOID
# cbSchemaName : SHORT -> short
# szTableName : BYTE* optional -> LPVOID
# cbTableName : SHORT -> short
# szColumnName : BYTE* optional -> LPVOID
# cbColumnName : SHORT -> short
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

文字セット違い