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