ホーム › 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 | カタログ(データベース)名。ANSI文字列。NULL可。 |
| NameLength1 | SHORT | in | CatalogNameの文字数。SQL_NTSでNUL終端を示す。 |
| SchemaName | BYTE* | inoptional | スキーマ名。ANSI文字列。NULL可。 |
| NameLength2 | SHORT | in | SchemaNameの文字数。SQL_NTSでNUL終端を示す。 |
| TableName | BYTE* | inoptional | テーブル名。ANSI文字列。NULL不可。 |
| NameLength3 | SHORT | in | TableNameの文字数。SQL_NTSでNUL終端を示す。 |
| Unique | WORD | in | 返すインデックス種別。SQL_INDEX_UNIQUE/SQL_INDEX_ALLを指定する。 |
| Reserved | WORD | in | 統計の取得精度。SQL_ENSURE/SQL_QUICKを指定する。 |
戻り値の型: 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)。const std = @import("std");
extern "odbc32" fn SQLStatistics(
StatementHandle: ?*anyopaque, // void* in/out
CatalogName: [*c]u8, // BYTE* optional
NameLength1: i16, // SHORT
SchemaName: [*c]u8, // BYTE* optional
NameLength2: i16, // SHORT
TableName: [*c]u8, // BYTE* optional
NameLength3: i16, // SHORT
Unique: u16, // WORD
Reserved: u16 // WORD
) callconv(std.os.windows.WINAPI) i16;proc SQLStatistics(
StatementHandle: pointer, # void* in/out
CatalogName: ptr uint8, # BYTE* optional
NameLength1: int16, # SHORT
SchemaName: ptr uint8, # BYTE* optional
NameLength2: int16, # SHORT
TableName: ptr uint8, # BYTE* optional
NameLength3: int16, # SHORT
Unique: uint16, # WORD
Reserved: uint16 # WORD
): int16 {.importc: "SQLStatistics", stdcall, dynlib: "ODBC32.dll".}pragma(lib, "odbc32");
extern(Windows)
short SQLStatistics(
void* StatementHandle, // void* in/out
ubyte* CatalogName, // BYTE* optional
short NameLength1, // SHORT
ubyte* SchemaName, // BYTE* optional
short NameLength2, // SHORT
ubyte* TableName, // BYTE* optional
short NameLength3, // SHORT
ushort Unique, // WORD
ushort Reserved // WORD
);ccall((:SQLStatistics, "ODBC32.dll"), stdcall, Int16,
(Ptr{Cvoid}, Ptr{UInt8}, Int16, Ptr{UInt8}, Int16, Ptr{UInt8}, Int16, UInt16, UInt16),
StatementHandle, CatalogName, NameLength1, SchemaName, NameLength2, TableName, NameLength3, Unique, Reserved)
# StatementHandle : void* in/out -> Ptr{Cvoid}
# CatalogName : BYTE* optional -> Ptr{UInt8}
# NameLength1 : SHORT -> Int16
# SchemaName : BYTE* optional -> Ptr{UInt8}
# NameLength2 : SHORT -> Int16
# TableName : BYTE* optional -> Ptr{UInt8}
# NameLength3 : SHORT -> Int16
# Unique : WORD -> UInt16
# Reserved : WORD -> UInt16
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int16_t SQLStatistics(
void* StatementHandle,
uint8_t* CatalogName,
int16_t NameLength1,
uint8_t* SchemaName,
int16_t NameLength2,
uint8_t* TableName,
int16_t NameLength3,
uint16_t Unique,
uint16_t Reserved);
]]
local odbc32 = ffi.load("odbc32")
-- odbc32.SQLStatistics(StatementHandle, CatalogName, NameLength1, SchemaName, NameLength2, TableName, NameLength3, Unique, Reserved)
-- StatementHandle : void* in/out
-- CatalogName : BYTE* optional
-- NameLength1 : SHORT
-- SchemaName : BYTE* optional
-- NameLength2 : SHORT
-- TableName : BYTE* optional
-- NameLength3 : SHORT
-- Unique : WORD
-- Reserved : WORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('ODBC32.dll');
const SQLStatistics = lib.func('__stdcall', 'SQLStatistics', 'int16_t', ['void *', 'uint8_t *', 'int16_t', 'uint8_t *', 'int16_t', 'uint8_t *', 'int16_t', 'uint16_t', 'uint16_t']);
// SQLStatistics(StatementHandle, CatalogName, NameLength1, SchemaName, NameLength2, TableName, NameLength3, Unique, Reserved)
// StatementHandle : void* in/out -> 'void *'
// CatalogName : BYTE* optional -> 'uint8_t *'
// NameLength1 : SHORT -> 'int16_t'
// SchemaName : BYTE* optional -> 'uint8_t *'
// NameLength2 : SHORT -> 'int16_t'
// TableName : BYTE* optional -> 'uint8_t *'
// NameLength3 : SHORT -> 'int16_t'
// Unique : WORD -> 'uint16_t'
// Reserved : WORD -> 'uint16_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("ODBC32.dll", {
SQLStatistics: { parameters: ["pointer", "pointer", "i16", "pointer", "i16", "pointer", "i16", "u16", "u16"], result: "i16" },
});
// lib.symbols.SQLStatistics(StatementHandle, CatalogName, NameLength1, SchemaName, NameLength2, TableName, NameLength3, Unique, Reserved)
// StatementHandle : void* in/out -> "pointer"
// CatalogName : BYTE* optional -> "pointer"
// NameLength1 : SHORT -> "i16"
// SchemaName : BYTE* optional -> "pointer"
// NameLength2 : SHORT -> "i16"
// TableName : BYTE* optional -> "pointer"
// NameLength3 : SHORT -> "i16"
// Unique : WORD -> "u16"
// Reserved : WORD -> "u16"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int16_t SQLStatistics(
void* StatementHandle,
uint8_t* CatalogName,
int16_t NameLength1,
uint8_t* SchemaName,
int16_t NameLength2,
uint8_t* TableName,
int16_t NameLength3,
uint16_t Unique,
uint16_t Reserved);
C, "ODBC32.dll");
// $ffi->SQLStatistics(StatementHandle, CatalogName, NameLength1, SchemaName, NameLength2, TableName, NameLength3, Unique, Reserved);
// StatementHandle : void* in/out
// CatalogName : BYTE* optional
// NameLength1 : SHORT
// SchemaName : BYTE* optional
// NameLength2 : SHORT
// TableName : BYTE* optional
// NameLength3 : SHORT
// Unique : WORD
// Reserved : WORD
// 構造体/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.ASCII_OPTIONS);
short SQLStatistics(
Pointer StatementHandle, // void* in/out
byte[] CatalogName, // BYTE* optional
short NameLength1, // SHORT
byte[] SchemaName, // BYTE* optional
short NameLength2, // SHORT
byte[] TableName, // BYTE* optional
short NameLength3, // SHORT
short Unique, // WORD
short Reserved // WORD
);
}@[Link("odbc32")]
lib LibODBC32
fun SQLStatistics = SQLStatistics(
StatementHandle : Void*, # void* in/out
CatalogName : UInt8*, # BYTE* optional
NameLength1 : Int16, # SHORT
SchemaName : UInt8*, # BYTE* optional
NameLength2 : Int16, # SHORT
TableName : UInt8*, # BYTE* optional
NameLength3 : Int16, # SHORT
Unique : UInt16, # WORD
Reserved : UInt16 # WORD
) : Int16
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef SQLStatisticsNative = Int16 Function(Pointer<Void>, Pointer<Uint8>, Int16, Pointer<Uint8>, Int16, Pointer<Uint8>, Int16, Uint16, Uint16);
typedef SQLStatisticsDart = int Function(Pointer<Void>, Pointer<Uint8>, int, Pointer<Uint8>, int, Pointer<Uint8>, int, int, int);
final SQLStatistics = DynamicLibrary.open('ODBC32.dll')
.lookupFunction<SQLStatisticsNative, SQLStatisticsDart>('SQLStatistics');
// StatementHandle : void* in/out -> Pointer<Void>
// CatalogName : BYTE* optional -> Pointer<Uint8>
// NameLength1 : SHORT -> Int16
// SchemaName : BYTE* optional -> Pointer<Uint8>
// NameLength2 : SHORT -> Int16
// TableName : BYTE* optional -> Pointer<Uint8>
// NameLength3 : SHORT -> Int16
// Unique : WORD -> Uint16
// Reserved : WORD -> Uint16
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function 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';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SQLStatistics"
c_SQLStatistics :: Ptr () -> Ptr Word8 -> Int16 -> Ptr Word8 -> Int16 -> Ptr Word8 -> Int16 -> Word16 -> Word16 -> IO Int16
-- StatementHandle : void* in/out -> Ptr ()
-- CatalogName : BYTE* optional -> Ptr Word8
-- NameLength1 : SHORT -> Int16
-- SchemaName : BYTE* optional -> Ptr Word8
-- NameLength2 : SHORT -> Int16
-- TableName : BYTE* optional -> Ptr Word8
-- NameLength3 : SHORT -> Int16
-- Unique : WORD -> Word16
-- Reserved : WORD -> Word16
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let sqlstatistics =
foreign "SQLStatistics"
((ptr void) @-> (ptr uint8_t) @-> int16_t @-> (ptr uint8_t) @-> int16_t @-> (ptr uint8_t) @-> int16_t @-> uint16_t @-> uint16_t @-> returning int16_t)
(* StatementHandle : void* in/out -> (ptr void) *)
(* CatalogName : BYTE* optional -> (ptr uint8_t) *)
(* NameLength1 : SHORT -> int16_t *)
(* SchemaName : BYTE* optional -> (ptr uint8_t) *)
(* NameLength2 : SHORT -> int16_t *)
(* TableName : BYTE* optional -> (ptr uint8_t) *)
(* NameLength3 : SHORT -> int16_t *)
(* Unique : WORD -> uint16_t *)
(* Reserved : WORD -> uint16_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library odbc32 (t "ODBC32.dll"))
(cffi:use-foreign-library odbc32)
(cffi:defcfun ("SQLStatistics" sqlstatistics :convention :stdcall) :int16
(statement-handle :pointer) ; void* in/out
(catalog-name :pointer) ; BYTE* optional
(name-length1 :int16) ; SHORT
(schema-name :pointer) ; BYTE* optional
(name-length2 :int16) ; SHORT
(table-name :pointer) ; BYTE* optional
(name-length3 :int16) ; SHORT
(unique :uint16) ; WORD
(reserved :uint16)) ; WORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SQLStatistics = Win32::API::More->new('ODBC32',
'short SQLStatistics(LPVOID StatementHandle, LPVOID CatalogName, short NameLength1, LPVOID SchemaName, short NameLength2, LPVOID TableName, short NameLength3, WORD Unique, WORD Reserved)');
# my $ret = $SQLStatistics->Call($StatementHandle, $CatalogName, $NameLength1, $SchemaName, $NameLength2, $TableName, $NameLength3, $Unique, $Reserved);
# StatementHandle : void* in/out -> LPVOID
# CatalogName : BYTE* optional -> LPVOID
# NameLength1 : SHORT -> short
# SchemaName : BYTE* optional -> LPVOID
# NameLength2 : SHORT -> short
# TableName : BYTE* optional -> LPVOID
# NameLength3 : SHORT -> short
# Unique : WORD -> WORD
# Reserved : WORD -> WORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
文字セット違い
- f SQLStatisticsA (ANSI版) — テーブルとそのインデックスの統計情報を取得する。
- f SQLStatisticsW (Unicode版) — テーブルの統計情報とインデックス一覧を返す(Unicode)。