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