ホーム › System.Search › SQLTablesW
SQLTablesW
関数データソース内のテーブル一覧を結果セットで返す(Unicode)。
シグネチャ
// ODBC32.dll (Unicode / -W)
#include <windows.h>
SHORT SQLTablesW(
void* hstmt,
WORD* szCatalogName, // optional
SHORT cchCatalogName,
WORD* szSchemaName, // optional
SHORT cchSchemaName,
WORD* szTableName, // optional
SHORT cchTableName,
WORD* szTableType, // optional
SHORT cchTableType
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hstmt | void* | inout | 結果セットを生成する対象のステートメントハンドル。 |
| szCatalogName | WORD* | inoptional | カタログ名。検索パターンまたはNULL可。Unicode文字列。 |
| cchCatalogName | SHORT | in | szCatalogNameの文字数。SQL_NTSでNUL終端を示す。 |
| szSchemaName | WORD* | inoptional | スキーマ名。検索パターンまたはNULL可。Unicode文字列。 |
| cchSchemaName | SHORT | in | szSchemaNameの文字数。SQL_NTSでNUL終端を示す。 |
| szTableName | WORD* | inoptional | テーブル名。検索パターンまたはNULL可。Unicode文字列。 |
| cchTableName | SHORT | in | szTableNameの文字数。SQL_NTSでNUL終端を示す。 |
| szTableType | WORD* | inoptional | 取得するテーブル種別のカンマ区切りリスト。TABLE/VIEW等。NULL可。 |
| cchTableType | SHORT | in | szTableTypeの文字数。SQL_NTSでNUL終端を示す。 |
戻り値の型: SHORT
各言語での呼び出し定義
// ODBC32.dll (Unicode / -W)
#include <windows.h>
SHORT SQLTablesW(
void* hstmt,
WORD* szCatalogName, // optional
SHORT cchCatalogName,
WORD* szSchemaName, // optional
SHORT cchSchemaName,
WORD* szTableName, // optional
SHORT cchTableName,
WORD* szTableType, // optional
SHORT cchTableType
);[DllImport("ODBC32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern short SQLTablesW(
IntPtr hstmt, // void* in/out
IntPtr szCatalogName, // WORD* optional
short cchCatalogName, // SHORT
IntPtr szSchemaName, // WORD* optional
short cchSchemaName, // SHORT
IntPtr szTableName, // WORD* optional
short cchTableName, // SHORT
IntPtr szTableType, // WORD* optional
short cchTableType // SHORT
);<DllImport("ODBC32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function SQLTablesW(
hstmt As IntPtr, ' void* in/out
szCatalogName As IntPtr, ' WORD* optional
cchCatalogName As Short, ' SHORT
szSchemaName As IntPtr, ' WORD* optional
cchSchemaName As Short, ' SHORT
szTableName As IntPtr, ' WORD* optional
cchTableName As Short, ' SHORT
szTableType As IntPtr, ' WORD* optional
cchTableType As Short ' SHORT
) As Short
End Function' hstmt : void* in/out
' szCatalogName : WORD* optional
' cchCatalogName : SHORT
' szSchemaName : WORD* optional
' cchSchemaName : SHORT
' szTableName : WORD* optional
' cchTableName : SHORT
' szTableType : WORD* optional
' cchTableType : SHORT
Declare PtrSafe Function SQLTablesW Lib "odbc32" ( _
ByVal hstmt As LongPtr, _
ByVal szCatalogName As LongPtr, _
ByVal cchCatalogName As Integer, _
ByVal szSchemaName As LongPtr, _
ByVal cchSchemaName As Integer, _
ByVal szTableName As LongPtr, _
ByVal cchTableName As Integer, _
ByVal szTableType As LongPtr, _
ByVal cchTableType As Integer) 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
SQLTablesW = ctypes.windll.odbc32.SQLTablesW
SQLTablesW.restype = ctypes.c_short
SQLTablesW.argtypes = [
ctypes.POINTER(None), # hstmt : void* in/out
ctypes.POINTER(ctypes.c_ushort), # szCatalogName : WORD* optional
ctypes.c_short, # cchCatalogName : SHORT
ctypes.POINTER(ctypes.c_ushort), # szSchemaName : WORD* optional
ctypes.c_short, # cchSchemaName : SHORT
ctypes.POINTER(ctypes.c_ushort), # szTableName : WORD* optional
ctypes.c_short, # cchTableName : SHORT
ctypes.POINTER(ctypes.c_ushort), # szTableType : WORD* optional
ctypes.c_short, # cchTableType : SHORT
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ODBC32.dll')
SQLTablesW = Fiddle::Function.new(
lib['SQLTablesW'],
[
Fiddle::TYPE_VOIDP, # hstmt : void* in/out
Fiddle::TYPE_VOIDP, # szCatalogName : WORD* optional
Fiddle::TYPE_SHORT, # cchCatalogName : SHORT
Fiddle::TYPE_VOIDP, # szSchemaName : WORD* optional
Fiddle::TYPE_SHORT, # cchSchemaName : SHORT
Fiddle::TYPE_VOIDP, # szTableName : WORD* optional
Fiddle::TYPE_SHORT, # cchTableName : SHORT
Fiddle::TYPE_VOIDP, # szTableType : WORD* optional
Fiddle::TYPE_SHORT, # cchTableType : SHORT
],
Fiddle::TYPE_SHORT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "odbc32")]
extern "system" {
fn SQLTablesW(
hstmt: *mut (), // void* in/out
szCatalogName: *mut u16, // WORD* optional
cchCatalogName: i16, // SHORT
szSchemaName: *mut u16, // WORD* optional
cchSchemaName: i16, // SHORT
szTableName: *mut u16, // WORD* optional
cchTableName: i16, // SHORT
szTableType: *mut u16, // WORD* optional
cchTableType: i16 // SHORT
) -> i16;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ODBC32.dll", CharSet = CharSet.Unicode)]
public static extern short SQLTablesW(IntPtr hstmt, IntPtr szCatalogName, short cchCatalogName, IntPtr szSchemaName, short cchSchemaName, IntPtr szTableName, short cchTableName, IntPtr szTableType, short cchTableType);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ODBC32_SQLTablesW' -Namespace Win32 -PassThru
# $api::SQLTablesW(hstmt, szCatalogName, cchCatalogName, szSchemaName, cchSchemaName, szTableName, cchTableName, szTableType, cchTableType)#uselib "ODBC32.dll"
#func global SQLTablesW "SQLTablesW" wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr
; SQLTablesW hstmt, varptr(szCatalogName), cchCatalogName, varptr(szSchemaName), cchSchemaName, varptr(szTableName), cchTableName, varptr(szTableType), cchTableType ; 戻り値は stat
; hstmt : void* in/out -> "wptr"
; szCatalogName : WORD* optional -> "wptr"
; cchCatalogName : SHORT -> "wptr"
; szSchemaName : WORD* optional -> "wptr"
; cchSchemaName : SHORT -> "wptr"
; szTableName : WORD* optional -> "wptr"
; cchTableName : SHORT -> "wptr"
; szTableType : WORD* optional -> "wptr"
; cchTableType : SHORT -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "ODBC32.dll" #cfunc global SQLTablesW "SQLTablesW" sptr, var, int, var, int, var, int, var, int ; res = SQLTablesW(hstmt, szCatalogName, cchCatalogName, szSchemaName, cchSchemaName, szTableName, cchTableName, szTableType, cchTableType) ; hstmt : void* in/out -> "sptr" ; szCatalogName : WORD* optional -> "var" ; cchCatalogName : SHORT -> "int" ; szSchemaName : WORD* optional -> "var" ; cchSchemaName : SHORT -> "int" ; szTableName : WORD* optional -> "var" ; cchTableName : SHORT -> "int" ; szTableType : WORD* optional -> "var" ; cchTableType : SHORT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ODBC32.dll" #cfunc global SQLTablesW "SQLTablesW" sptr, sptr, int, sptr, int, sptr, int, sptr, int ; res = SQLTablesW(hstmt, varptr(szCatalogName), cchCatalogName, varptr(szSchemaName), cchSchemaName, varptr(szTableName), cchTableName, varptr(szTableType), cchTableType) ; hstmt : void* in/out -> "sptr" ; szCatalogName : WORD* optional -> "sptr" ; cchCatalogName : SHORT -> "int" ; szSchemaName : WORD* optional -> "sptr" ; cchSchemaName : SHORT -> "int" ; szTableName : WORD* optional -> "sptr" ; cchTableName : SHORT -> "int" ; szTableType : WORD* optional -> "sptr" ; cchTableType : SHORT -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; SHORT SQLTablesW(void* hstmt, WORD* szCatalogName, SHORT cchCatalogName, WORD* szSchemaName, SHORT cchSchemaName, WORD* szTableName, SHORT cchTableName, WORD* szTableType, SHORT cchTableType) #uselib "ODBC32.dll" #cfunc global SQLTablesW "SQLTablesW" intptr, var, int, var, int, var, int, var, int ; res = SQLTablesW(hstmt, szCatalogName, cchCatalogName, szSchemaName, cchSchemaName, szTableName, cchTableName, szTableType, cchTableType) ; hstmt : void* in/out -> "intptr" ; szCatalogName : WORD* optional -> "var" ; cchCatalogName : SHORT -> "int" ; szSchemaName : WORD* optional -> "var" ; cchSchemaName : SHORT -> "int" ; szTableName : WORD* optional -> "var" ; cchTableName : SHORT -> "int" ; szTableType : WORD* optional -> "var" ; cchTableType : SHORT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; SHORT SQLTablesW(void* hstmt, WORD* szCatalogName, SHORT cchCatalogName, WORD* szSchemaName, SHORT cchSchemaName, WORD* szTableName, SHORT cchTableName, WORD* szTableType, SHORT cchTableType) #uselib "ODBC32.dll" #cfunc global SQLTablesW "SQLTablesW" intptr, intptr, int, intptr, int, intptr, int, intptr, int ; res = SQLTablesW(hstmt, varptr(szCatalogName), cchCatalogName, varptr(szSchemaName), cchSchemaName, varptr(szTableName), cchTableName, varptr(szTableType), cchTableType) ; hstmt : void* in/out -> "intptr" ; szCatalogName : WORD* optional -> "intptr" ; cchCatalogName : SHORT -> "int" ; szSchemaName : WORD* optional -> "intptr" ; cchSchemaName : SHORT -> "int" ; szTableName : WORD* optional -> "intptr" ; cchTableName : SHORT -> "int" ; szTableType : WORD* optional -> "intptr" ; cchTableType : SHORT -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
odbc32 = windows.NewLazySystemDLL("ODBC32.dll")
procSQLTablesW = odbc32.NewProc("SQLTablesW")
)
// hstmt (void* in/out), szCatalogName (WORD* optional), cchCatalogName (SHORT), szSchemaName (WORD* optional), cchSchemaName (SHORT), szTableName (WORD* optional), cchTableName (SHORT), szTableType (WORD* optional), cchTableType (SHORT)
r1, _, err := procSQLTablesW.Call(
uintptr(hstmt),
uintptr(szCatalogName),
uintptr(cchCatalogName),
uintptr(szSchemaName),
uintptr(cchSchemaName),
uintptr(szTableName),
uintptr(cchTableName),
uintptr(szTableType),
uintptr(cchTableType),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // SHORTfunction SQLTablesW(
hstmt: Pointer; // void* in/out
szCatalogName: Pointer; // WORD* optional
cchCatalogName: Smallint; // SHORT
szSchemaName: Pointer; // WORD* optional
cchSchemaName: Smallint; // SHORT
szTableName: Pointer; // WORD* optional
cchTableName: Smallint; // SHORT
szTableType: Pointer; // WORD* optional
cchTableType: Smallint // SHORT
): Smallint; stdcall;
external 'ODBC32.dll' name 'SQLTablesW';result := DllCall("ODBC32\SQLTablesW"
, "Ptr", hstmt ; void* in/out
, "Ptr", szCatalogName ; WORD* optional
, "Short", cchCatalogName ; SHORT
, "Ptr", szSchemaName ; WORD* optional
, "Short", cchSchemaName ; SHORT
, "Ptr", szTableName ; WORD* optional
, "Short", cchTableName ; SHORT
, "Ptr", szTableType ; WORD* optional
, "Short", cchTableType ; SHORT
, "Short") ; return: SHORT●SQLTablesW(hstmt, szCatalogName, cchCatalogName, szSchemaName, cchSchemaName, szTableName, cchTableName, szTableType, cchTableType) = DLL("ODBC32.dll", "int SQLTablesW(void*, void*, int, void*, int, void*, int, void*, int)")
# 呼び出し: SQLTablesW(hstmt, szCatalogName, cchCatalogName, szSchemaName, cchSchemaName, szTableName, cchTableName, szTableType, cchTableType)
# hstmt : void* in/out -> "void*"
# szCatalogName : WORD* optional -> "void*"
# cchCatalogName : SHORT -> "int"
# szSchemaName : WORD* optional -> "void*"
# cchSchemaName : SHORT -> "int"
# szTableName : WORD* optional -> "void*"
# cchTableName : SHORT -> "int"
# szTableType : WORD* optional -> "void*"
# cchTableType : SHORT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。const std = @import("std");
extern "odbc32" fn SQLTablesW(
hstmt: ?*anyopaque, // void* in/out
szCatalogName: [*c]u16, // WORD* optional
cchCatalogName: i16, // SHORT
szSchemaName: [*c]u16, // WORD* optional
cchSchemaName: i16, // SHORT
szTableName: [*c]u16, // WORD* optional
cchTableName: i16, // SHORT
szTableType: [*c]u16, // WORD* optional
cchTableType: i16 // SHORT
) callconv(std.os.windows.WINAPI) i16;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc SQLTablesW(
hstmt: pointer, # void* in/out
szCatalogName: ptr uint16, # WORD* optional
cchCatalogName: int16, # SHORT
szSchemaName: ptr uint16, # WORD* optional
cchSchemaName: int16, # SHORT
szTableName: ptr uint16, # WORD* optional
cchTableName: int16, # SHORT
szTableType: ptr uint16, # WORD* optional
cchTableType: int16 # SHORT
): int16 {.importc: "SQLTablesW", stdcall, dynlib: "ODBC32.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "odbc32");
extern(Windows)
short SQLTablesW(
void* hstmt, // void* in/out
ushort* szCatalogName, // WORD* optional
short cchCatalogName, // SHORT
ushort* szSchemaName, // WORD* optional
short cchSchemaName, // SHORT
ushort* szTableName, // WORD* optional
short cchTableName, // SHORT
ushort* szTableType, // WORD* optional
short cchTableType // SHORT
);ccall((:SQLTablesW, "ODBC32.dll"), stdcall, Int16,
(Ptr{Cvoid}, Ptr{UInt16}, Int16, Ptr{UInt16}, Int16, Ptr{UInt16}, Int16, Ptr{UInt16}, Int16),
hstmt, szCatalogName, cchCatalogName, szSchemaName, cchSchemaName, szTableName, cchTableName, szTableType, cchTableType)
# hstmt : void* in/out -> Ptr{Cvoid}
# szCatalogName : WORD* optional -> Ptr{UInt16}
# cchCatalogName : SHORT -> Int16
# szSchemaName : WORD* optional -> Ptr{UInt16}
# cchSchemaName : SHORT -> Int16
# szTableName : WORD* optional -> Ptr{UInt16}
# cchTableName : SHORT -> Int16
# szTableType : WORD* optional -> Ptr{UInt16}
# cchTableType : SHORT -> Int16
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
int16_t SQLTablesW(
void* hstmt,
uint16_t* szCatalogName,
int16_t cchCatalogName,
uint16_t* szSchemaName,
int16_t cchSchemaName,
uint16_t* szTableName,
int16_t cchTableName,
uint16_t* szTableType,
int16_t cchTableType);
]]
local odbc32 = ffi.load("odbc32")
-- odbc32.SQLTablesW(hstmt, szCatalogName, cchCatalogName, szSchemaName, cchSchemaName, szTableName, cchTableName, szTableType, cchTableType)
-- hstmt : void* in/out
-- szCatalogName : WORD* optional
-- cchCatalogName : SHORT
-- szSchemaName : WORD* optional
-- cchSchemaName : SHORT
-- szTableName : WORD* optional
-- cchTableName : SHORT
-- szTableType : WORD* optional
-- cchTableType : SHORT
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。const koffi = require('koffi');
const lib = koffi.load('ODBC32.dll');
const SQLTablesW = lib.func('__stdcall', 'SQLTablesW', 'int16_t', ['void *', 'uint16_t *', 'int16_t', 'uint16_t *', 'int16_t', 'uint16_t *', 'int16_t', 'uint16_t *', 'int16_t']);
// SQLTablesW(hstmt, szCatalogName, cchCatalogName, szSchemaName, cchSchemaName, szTableName, cchTableName, szTableType, cchTableType)
// hstmt : void* in/out -> 'void *'
// szCatalogName : WORD* optional -> 'uint16_t *'
// cchCatalogName : SHORT -> 'int16_t'
// szSchemaName : WORD* optional -> 'uint16_t *'
// cchSchemaName : SHORT -> 'int16_t'
// szTableName : WORD* optional -> 'uint16_t *'
// cchTableName : SHORT -> 'int16_t'
// szTableType : WORD* optional -> 'uint16_t *'
// cchTableType : SHORT -> 'int16_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("ODBC32.dll", {
SQLTablesW: { parameters: ["pointer", "pointer", "i16", "pointer", "i16", "pointer", "i16", "pointer", "i16"], result: "i16" },
});
// lib.symbols.SQLTablesW(hstmt, szCatalogName, cchCatalogName, szSchemaName, cchSchemaName, szTableName, cchTableName, szTableType, cchTableType)
// hstmt : void* in/out -> "pointer"
// szCatalogName : WORD* optional -> "pointer"
// cchCatalogName : SHORT -> "i16"
// szSchemaName : WORD* optional -> "pointer"
// cchSchemaName : SHORT -> "i16"
// szTableName : WORD* optional -> "pointer"
// cchTableName : SHORT -> "i16"
// szTableType : WORD* optional -> "pointer"
// cchTableType : SHORT -> "i16"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int16_t SQLTablesW(
void* hstmt,
uint16_t* szCatalogName,
int16_t cchCatalogName,
uint16_t* szSchemaName,
int16_t cchSchemaName,
uint16_t* szTableName,
int16_t cchTableName,
uint16_t* szTableType,
int16_t cchTableType);
C, "ODBC32.dll");
// $ffi->SQLTablesW(hstmt, szCatalogName, cchCatalogName, szSchemaName, cchSchemaName, szTableName, cchTableName, szTableType, cchTableType);
// hstmt : void* in/out
// szCatalogName : WORD* optional
// cchCatalogName : SHORT
// szSchemaName : WORD* optional
// cchSchemaName : SHORT
// szTableName : WORD* optional
// cchTableName : SHORT
// szTableType : WORD* optional
// cchTableType : 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.UNICODE_OPTIONS);
short SQLTablesW(
Pointer hstmt, // void* in/out
ShortByReference szCatalogName, // WORD* optional
short cchCatalogName, // SHORT
ShortByReference szSchemaName, // WORD* optional
short cchSchemaName, // SHORT
ShortByReference szTableName, // WORD* optional
short cchTableName, // SHORT
ShortByReference szTableType, // WORD* optional
short cchTableType // SHORT
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("odbc32")]
lib LibODBC32
fun SQLTablesW = SQLTablesW(
hstmt : Void*, # void* in/out
szCatalogName : UInt16*, # WORD* optional
cchCatalogName : Int16, # SHORT
szSchemaName : UInt16*, # WORD* optional
cchSchemaName : Int16, # SHORT
szTableName : UInt16*, # WORD* optional
cchTableName : Int16, # SHORT
szTableType : UInt16*, # WORD* optional
cchTableType : 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 SQLTablesWNative = Int16 Function(Pointer<Void>, Pointer<Uint16>, Int16, Pointer<Uint16>, Int16, Pointer<Uint16>, Int16, Pointer<Uint16>, Int16);
typedef SQLTablesWDart = int Function(Pointer<Void>, Pointer<Uint16>, int, Pointer<Uint16>, int, Pointer<Uint16>, int, Pointer<Uint16>, int);
final SQLTablesW = DynamicLibrary.open('ODBC32.dll')
.lookupFunction<SQLTablesWNative, SQLTablesWDart>('SQLTablesW');
// hstmt : void* in/out -> Pointer<Void>
// szCatalogName : WORD* optional -> Pointer<Uint16>
// cchCatalogName : SHORT -> Int16
// szSchemaName : WORD* optional -> Pointer<Uint16>
// cchSchemaName : SHORT -> Int16
// szTableName : WORD* optional -> Pointer<Uint16>
// cchTableName : SHORT -> Int16
// szTableType : WORD* optional -> Pointer<Uint16>
// cchTableType : SHORT -> Int16
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SQLTablesW(
hstmt: Pointer; // void* in/out
szCatalogName: Pointer; // WORD* optional
cchCatalogName: Smallint; // SHORT
szSchemaName: Pointer; // WORD* optional
cchSchemaName: Smallint; // SHORT
szTableName: Pointer; // WORD* optional
cchTableName: Smallint; // SHORT
szTableType: Pointer; // WORD* optional
cchTableType: Smallint // SHORT
): Smallint; stdcall;
external 'ODBC32.dll' name 'SQLTablesW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SQLTablesW"
c_SQLTablesW :: Ptr () -> Ptr Word16 -> Int16 -> Ptr Word16 -> Int16 -> Ptr Word16 -> Int16 -> Ptr Word16 -> Int16 -> IO Int16
-- hstmt : void* in/out -> Ptr ()
-- szCatalogName : WORD* optional -> Ptr Word16
-- cchCatalogName : SHORT -> Int16
-- szSchemaName : WORD* optional -> Ptr Word16
-- cchSchemaName : SHORT -> Int16
-- szTableName : WORD* optional -> Ptr Word16
-- cchTableName : SHORT -> Int16
-- szTableType : WORD* optional -> Ptr Word16
-- cchTableType : SHORT -> Int16
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let sqltablesw =
foreign "SQLTablesW"
((ptr void) @-> (ptr uint16_t) @-> int16_t @-> (ptr uint16_t) @-> int16_t @-> (ptr uint16_t) @-> int16_t @-> (ptr uint16_t) @-> int16_t @-> returning int16_t)
(* hstmt : void* in/out -> (ptr void) *)
(* szCatalogName : WORD* optional -> (ptr uint16_t) *)
(* cchCatalogName : SHORT -> int16_t *)
(* szSchemaName : WORD* optional -> (ptr uint16_t) *)
(* cchSchemaName : SHORT -> int16_t *)
(* szTableName : WORD* optional -> (ptr uint16_t) *)
(* cchTableName : SHORT -> int16_t *)
(* szTableType : WORD* optional -> (ptr uint16_t) *)
(* cchTableType : 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 ("SQLTablesW" sqltables-w :convention :stdcall) :int16
(hstmt :pointer) ; void* in/out
(sz-catalog-name :pointer) ; WORD* optional
(cch-catalog-name :int16) ; SHORT
(sz-schema-name :pointer) ; WORD* optional
(cch-schema-name :int16) ; SHORT
(sz-table-name :pointer) ; WORD* optional
(cch-table-name :int16) ; SHORT
(sz-table-type :pointer) ; WORD* optional
(cch-table-type :int16)) ; SHORT
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SQLTablesW = Win32::API::More->new('ODBC32',
'short SQLTablesW(LPVOID hstmt, LPVOID szCatalogName, short cchCatalogName, LPVOID szSchemaName, short cchSchemaName, LPVOID szTableName, short cchTableName, LPVOID szTableType, short cchTableType)');
# my $ret = $SQLTablesW->Call($hstmt, $szCatalogName, $cchCatalogName, $szSchemaName, $cchSchemaName, $szTableName, $cchTableName, $szTableType, $cchTableType);
# hstmt : void* in/out -> LPVOID
# szCatalogName : WORD* optional -> LPVOID
# cchCatalogName : SHORT -> short
# szSchemaName : WORD* optional -> LPVOID
# cchSchemaName : SHORT -> short
# szTableName : WORD* optional -> LPVOID
# cchTableName : SHORT -> short
# szTableType : WORD* optional -> LPVOID
# cchTableType : SHORT -> short
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
文字セット違い
- f SQLTablesA (ANSI版) — データソース内のテーブルの一覧情報を取得する。