ホーム › System.Search › SQLStatisticsW
SQLStatisticsW
関数テーブルの統計情報とインデックス一覧を返す(Unicode)。
シグネチャ
// ODBC32.dll (Unicode / -W)
#include <windows.h>
SHORT SQLStatisticsW(
void* hstmt,
WORD* szCatalogName, // optional
SHORT cchCatalogName,
WORD* szSchemaName, // optional
SHORT cchSchemaName,
WORD* szTableName, // optional
SHORT cchTableName,
WORD fUnique,
WORD fAccuracy
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hstmt | void* | inout |
| szCatalogName | WORD* | inoptional |
| cchCatalogName | SHORT | in |
| szSchemaName | WORD* | inoptional |
| cchSchemaName | SHORT | in |
| szTableName | WORD* | inoptional |
| cchTableName | SHORT | in |
| fUnique | WORD | in |
| fAccuracy | WORD | in |
戻り値の型: SHORT
各言語での呼び出し定義
// ODBC32.dll (Unicode / -W)
#include <windows.h>
SHORT SQLStatisticsW(
void* hstmt,
WORD* szCatalogName, // optional
SHORT cchCatalogName,
WORD* szSchemaName, // optional
SHORT cchSchemaName,
WORD* szTableName, // optional
SHORT cchTableName,
WORD fUnique,
WORD fAccuracy
);[DllImport("ODBC32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern short SQLStatisticsW(
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
ushort fUnique, // WORD
ushort fAccuracy // WORD
);<DllImport("ODBC32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function SQLStatisticsW(
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
fUnique As UShort, ' WORD
fAccuracy As UShort ' WORD
) As Short
End Function' hstmt : void* in/out
' szCatalogName : WORD* optional
' cchCatalogName : SHORT
' szSchemaName : WORD* optional
' cchSchemaName : SHORT
' szTableName : WORD* optional
' cchTableName : SHORT
' fUnique : WORD
' fAccuracy : WORD
Declare PtrSafe Function SQLStatisticsW 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 fUnique As Integer, _
ByVal fAccuracy 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
SQLStatisticsW = ctypes.windll.odbc32.SQLStatisticsW
SQLStatisticsW.restype = ctypes.c_short
SQLStatisticsW.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.c_ushort, # fUnique : WORD
ctypes.c_ushort, # fAccuracy : WORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ODBC32.dll')
SQLStatisticsW = Fiddle::Function.new(
lib['SQLStatisticsW'],
[
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_SHORT, # fUnique : WORD
-Fiddle::TYPE_SHORT, # fAccuracy : WORD
],
Fiddle::TYPE_SHORT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "odbc32")]
extern "system" {
fn SQLStatisticsW(
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
fUnique: u16, // WORD
fAccuracy: u16 // WORD
) -> i16;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ODBC32.dll", CharSet = CharSet.Unicode)]
public static extern short SQLStatisticsW(IntPtr hstmt, IntPtr szCatalogName, short cchCatalogName, IntPtr szSchemaName, short cchSchemaName, IntPtr szTableName, short cchTableName, ushort fUnique, ushort fAccuracy);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ODBC32_SQLStatisticsW' -Namespace Win32 -PassThru
# $api::SQLStatisticsW(hstmt, szCatalogName, cchCatalogName, szSchemaName, cchSchemaName, szTableName, cchTableName, fUnique, fAccuracy)#uselib "ODBC32.dll"
#func global SQLStatisticsW "SQLStatisticsW" wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr
; SQLStatisticsW hstmt, varptr(szCatalogName), cchCatalogName, varptr(szSchemaName), cchSchemaName, varptr(szTableName), cchTableName, fUnique, fAccuracy ; 戻り値は 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"
; fUnique : WORD -> "wptr"
; fAccuracy : WORD -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "ODBC32.dll" #cfunc global SQLStatisticsW "SQLStatisticsW" sptr, var, int, var, int, var, int, int, int ; res = SQLStatisticsW(hstmt, szCatalogName, cchCatalogName, szSchemaName, cchSchemaName, szTableName, cchTableName, fUnique, fAccuracy) ; 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" ; fUnique : WORD -> "int" ; fAccuracy : WORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ODBC32.dll" #cfunc global SQLStatisticsW "SQLStatisticsW" sptr, sptr, int, sptr, int, sptr, int, int, int ; res = SQLStatisticsW(hstmt, varptr(szCatalogName), cchCatalogName, varptr(szSchemaName), cchSchemaName, varptr(szTableName), cchTableName, fUnique, fAccuracy) ; 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" ; fUnique : WORD -> "int" ; fAccuracy : WORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; SHORT SQLStatisticsW(void* hstmt, WORD* szCatalogName, SHORT cchCatalogName, WORD* szSchemaName, SHORT cchSchemaName, WORD* szTableName, SHORT cchTableName, WORD fUnique, WORD fAccuracy) #uselib "ODBC32.dll" #cfunc global SQLStatisticsW "SQLStatisticsW" intptr, var, int, var, int, var, int, int, int ; res = SQLStatisticsW(hstmt, szCatalogName, cchCatalogName, szSchemaName, cchSchemaName, szTableName, cchTableName, fUnique, fAccuracy) ; 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" ; fUnique : WORD -> "int" ; fAccuracy : WORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; SHORT SQLStatisticsW(void* hstmt, WORD* szCatalogName, SHORT cchCatalogName, WORD* szSchemaName, SHORT cchSchemaName, WORD* szTableName, SHORT cchTableName, WORD fUnique, WORD fAccuracy) #uselib "ODBC32.dll" #cfunc global SQLStatisticsW "SQLStatisticsW" intptr, intptr, int, intptr, int, intptr, int, int, int ; res = SQLStatisticsW(hstmt, varptr(szCatalogName), cchCatalogName, varptr(szSchemaName), cchSchemaName, varptr(szTableName), cchTableName, fUnique, fAccuracy) ; 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" ; fUnique : WORD -> "int" ; fAccuracy : WORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
odbc32 = windows.NewLazySystemDLL("ODBC32.dll")
procSQLStatisticsW = odbc32.NewProc("SQLStatisticsW")
)
// hstmt (void* in/out), szCatalogName (WORD* optional), cchCatalogName (SHORT), szSchemaName (WORD* optional), cchSchemaName (SHORT), szTableName (WORD* optional), cchTableName (SHORT), fUnique (WORD), fAccuracy (WORD)
r1, _, err := procSQLStatisticsW.Call(
uintptr(hstmt),
uintptr(szCatalogName),
uintptr(cchCatalogName),
uintptr(szSchemaName),
uintptr(cchSchemaName),
uintptr(szTableName),
uintptr(cchTableName),
uintptr(fUnique),
uintptr(fAccuracy),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // SHORTfunction SQLStatisticsW(
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
fUnique: Word; // WORD
fAccuracy: Word // WORD
): Smallint; stdcall;
external 'ODBC32.dll' name 'SQLStatisticsW';result := DllCall("ODBC32\SQLStatisticsW"
, "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
, "UShort", fUnique ; WORD
, "UShort", fAccuracy ; WORD
, "Short") ; return: SHORT●SQLStatisticsW(hstmt, szCatalogName, cchCatalogName, szSchemaName, cchSchemaName, szTableName, cchTableName, fUnique, fAccuracy) = DLL("ODBC32.dll", "int SQLStatisticsW(void*, void*, int, void*, int, void*, int, int, int)")
# 呼び出し: SQLStatisticsW(hstmt, szCatalogName, cchCatalogName, szSchemaName, cchSchemaName, szTableName, cchTableName, fUnique, fAccuracy)
# 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"
# fUnique : WORD -> "int"
# fAccuracy : WORD -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。