ホーム › System.Search › SQLTablesA
SQLTablesA
関数データソース内のテーブルの一覧情報を取得する。
シグネチャ
// ODBC32.dll (ANSI / -A)
#include <windows.h>
SHORT SQLTablesA(
void* hstmt,
BYTE* szCatalogName, // optional
SHORT cbCatalogName,
BYTE* szSchemaName, // optional
SHORT cbSchemaName,
BYTE* szTableName, // optional
SHORT cbTableName,
BYTE* szTableType, // optional
SHORT cbTableType
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hstmt | void* | inout |
| szCatalogName | BYTE* | inoptional |
| cbCatalogName | SHORT | in |
| szSchemaName | BYTE* | inoptional |
| cbSchemaName | SHORT | in |
| szTableName | BYTE* | inoptional |
| cbTableName | SHORT | in |
| szTableType | BYTE* | inoptional |
| cbTableType | SHORT | in |
戻り値の型: SHORT
各言語での呼び出し定義
// ODBC32.dll (ANSI / -A)
#include <windows.h>
SHORT SQLTablesA(
void* hstmt,
BYTE* szCatalogName, // optional
SHORT cbCatalogName,
BYTE* szSchemaName, // optional
SHORT cbSchemaName,
BYTE* szTableName, // optional
SHORT cbTableName,
BYTE* szTableType, // optional
SHORT cbTableType
);[DllImport("ODBC32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern short SQLTablesA(
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 szTableType, // BYTE* optional
short cbTableType // SHORT
);<DllImport("ODBC32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function SQLTablesA(
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
szTableType As IntPtr, ' BYTE* optional
cbTableType 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
' szTableType : BYTE* optional
' cbTableType : SHORT
Declare PtrSafe Function SQLTablesA 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 szTableType As LongPtr, _
ByVal cbTableType As Integer) As Integer
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SQLTablesA = ctypes.windll.odbc32.SQLTablesA
SQLTablesA.restype = ctypes.c_short
SQLTablesA.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), # szTableType : BYTE* optional
ctypes.c_short, # cbTableType : SHORT
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ODBC32.dll')
SQLTablesA = Fiddle::Function.new(
lib['SQLTablesA'],
[
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, # szTableType : BYTE* optional
Fiddle::TYPE_SHORT, # cbTableType : SHORT
],
Fiddle::TYPE_SHORT)#[link(name = "odbc32")]
extern "system" {
fn SQLTablesA(
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
szTableType: *mut u8, // BYTE* optional
cbTableType: i16 // SHORT
) -> i16;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ODBC32.dll", CharSet = CharSet.Ansi)]
public static extern short SQLTablesA(IntPtr hstmt, IntPtr szCatalogName, short cbCatalogName, IntPtr szSchemaName, short cbSchemaName, IntPtr szTableName, short cbTableName, IntPtr szTableType, short cbTableType);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ODBC32_SQLTablesA' -Namespace Win32 -PassThru
# $api::SQLTablesA(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, szTableName, cbTableName, szTableType, cbTableType)#uselib "ODBC32.dll"
#func global SQLTablesA "SQLTablesA" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; SQLTablesA hstmt, varptr(szCatalogName), cbCatalogName, varptr(szSchemaName), cbSchemaName, varptr(szTableName), cbTableName, varptr(szTableType), cbTableType ; 戻り値は 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"
; szTableType : BYTE* optional -> "sptr"
; cbTableType : SHORT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "ODBC32.dll" #cfunc global SQLTablesA "SQLTablesA" sptr, var, int, var, int, var, int, var, int ; res = SQLTablesA(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, szTableName, cbTableName, szTableType, cbTableType) ; 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" ; szTableType : BYTE* optional -> "var" ; cbTableType : SHORT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ODBC32.dll" #cfunc global SQLTablesA "SQLTablesA" sptr, sptr, int, sptr, int, sptr, int, sptr, int ; res = SQLTablesA(hstmt, varptr(szCatalogName), cbCatalogName, varptr(szSchemaName), cbSchemaName, varptr(szTableName), cbTableName, varptr(szTableType), cbTableType) ; hstmt : void* in/out -> "sptr" ; szCatalogName : BYTE* optional -> "sptr" ; cbCatalogName : SHORT -> "int" ; szSchemaName : BYTE* optional -> "sptr" ; cbSchemaName : SHORT -> "int" ; szTableName : BYTE* optional -> "sptr" ; cbTableName : SHORT -> "int" ; szTableType : BYTE* optional -> "sptr" ; cbTableType : SHORT -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; SHORT SQLTablesA(void* hstmt, BYTE* szCatalogName, SHORT cbCatalogName, BYTE* szSchemaName, SHORT cbSchemaName, BYTE* szTableName, SHORT cbTableName, BYTE* szTableType, SHORT cbTableType) #uselib "ODBC32.dll" #cfunc global SQLTablesA "SQLTablesA" intptr, var, int, var, int, var, int, var, int ; res = SQLTablesA(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, szTableName, cbTableName, szTableType, cbTableType) ; 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" ; szTableType : BYTE* optional -> "var" ; cbTableType : SHORT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; SHORT SQLTablesA(void* hstmt, BYTE* szCatalogName, SHORT cbCatalogName, BYTE* szSchemaName, SHORT cbSchemaName, BYTE* szTableName, SHORT cbTableName, BYTE* szTableType, SHORT cbTableType) #uselib "ODBC32.dll" #cfunc global SQLTablesA "SQLTablesA" intptr, intptr, int, intptr, int, intptr, int, intptr, int ; res = SQLTablesA(hstmt, varptr(szCatalogName), cbCatalogName, varptr(szSchemaName), cbSchemaName, varptr(szTableName), cbTableName, varptr(szTableType), cbTableType) ; hstmt : void* in/out -> "intptr" ; szCatalogName : BYTE* optional -> "intptr" ; cbCatalogName : SHORT -> "int" ; szSchemaName : BYTE* optional -> "intptr" ; cbSchemaName : SHORT -> "int" ; szTableName : BYTE* optional -> "intptr" ; cbTableName : SHORT -> "int" ; szTableType : BYTE* optional -> "intptr" ; cbTableType : SHORT -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
odbc32 = windows.NewLazySystemDLL("ODBC32.dll")
procSQLTablesA = odbc32.NewProc("SQLTablesA")
)
// hstmt (void* in/out), szCatalogName (BYTE* optional), cbCatalogName (SHORT), szSchemaName (BYTE* optional), cbSchemaName (SHORT), szTableName (BYTE* optional), cbTableName (SHORT), szTableType (BYTE* optional), cbTableType (SHORT)
r1, _, err := procSQLTablesA.Call(
uintptr(hstmt),
uintptr(szCatalogName),
uintptr(cbCatalogName),
uintptr(szSchemaName),
uintptr(cbSchemaName),
uintptr(szTableName),
uintptr(cbTableName),
uintptr(szTableType),
uintptr(cbTableType),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // SHORTfunction SQLTablesA(
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
szTableType: Pointer; // BYTE* optional
cbTableType: Smallint // SHORT
): Smallint; stdcall;
external 'ODBC32.dll' name 'SQLTablesA';result := DllCall("ODBC32\SQLTablesA"
, "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", szTableType ; BYTE* optional
, "Short", cbTableType ; SHORT
, "Short") ; return: SHORT●SQLTablesA(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, szTableName, cbTableName, szTableType, cbTableType) = DLL("ODBC32.dll", "int SQLTablesA(void*, void*, int, void*, int, void*, int, void*, int)")
# 呼び出し: SQLTablesA(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, szTableName, cbTableName, szTableType, cbTableType)
# 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"
# szTableType : BYTE* optional -> "void*"
# cbTableType : SHORT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。