ホーム › System.Search › SQLGetDescRecA
SQLGetDescRecA
関数記述子レコードの複数フィールド値をまとめて取得する(ANSI)。
シグネチャ
// ODBC32.dll (ANSI / -A)
#include <windows.h>
SHORT SQLGetDescRecA(
void* hdesc,
SHORT iRecord,
BYTE* szName, // optional
SHORT cbNameMax,
SHORT* pcbName, // optional
SHORT* pfType, // optional
SHORT* pfSubType, // optional
INT* pLength, // optional
SHORT* pPrecision, // optional
SHORT* pScale, // optional
SHORT* pNullable // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hdesc | void* | inout | ODBCの記述子ハンドル。レコード取得対象。 |
| iRecord | SHORT | in | 対象レコード番号。1始まりで指定する。 |
| szName | BYTE* | outoptional | 列名やパラメータ名を受け取るバッファ。出力用。 |
| cbNameMax | SHORT | in | szNameバッファのバイト長。 |
| pcbName | SHORT* | outoptional | 実際に返された名前のバイト長を受け取るポインタ。 |
| pfType | SHORT* | outoptional | データ型(SQL_*)を受け取るポインタ。 |
| pfSubType | SHORT* | outoptional | 日時/区間型の場合のサブタイプを受け取るポインタ。 |
| pLength | INT* | outoptional | データ長を受け取るポインタ。 |
| pPrecision | SHORT* | outoptional | 精度を受け取るポインタ。 |
| pScale | SHORT* | outoptional | スケール(小数桁数)を受け取るポインタ。 |
| pNullable | SHORT* | outoptional | NULL許容性(SQL_NULLABLE等)を受け取るポインタ。 |
戻り値の型: SHORT
各言語での呼び出し定義
// ODBC32.dll (ANSI / -A)
#include <windows.h>
SHORT SQLGetDescRecA(
void* hdesc,
SHORT iRecord,
BYTE* szName, // optional
SHORT cbNameMax,
SHORT* pcbName, // optional
SHORT* pfType, // optional
SHORT* pfSubType, // optional
INT* pLength, // optional
SHORT* pPrecision, // optional
SHORT* pScale, // optional
SHORT* pNullable // optional
);[DllImport("ODBC32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern short SQLGetDescRecA(
IntPtr hdesc, // void* in/out
short iRecord, // SHORT
IntPtr szName, // BYTE* optional, out
short cbNameMax, // SHORT
IntPtr pcbName, // SHORT* optional, out
IntPtr pfType, // SHORT* optional, out
IntPtr pfSubType, // SHORT* optional, out
IntPtr pLength, // INT* optional, out
IntPtr pPrecision, // SHORT* optional, out
IntPtr pScale, // SHORT* optional, out
IntPtr pNullable // SHORT* optional, out
);<DllImport("ODBC32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function SQLGetDescRecA(
hdesc As IntPtr, ' void* in/out
iRecord As Short, ' SHORT
szName As IntPtr, ' BYTE* optional, out
cbNameMax As Short, ' SHORT
pcbName As IntPtr, ' SHORT* optional, out
pfType As IntPtr, ' SHORT* optional, out
pfSubType As IntPtr, ' SHORT* optional, out
pLength As IntPtr, ' INT* optional, out
pPrecision As IntPtr, ' SHORT* optional, out
pScale As IntPtr, ' SHORT* optional, out
pNullable As IntPtr ' SHORT* optional, out
) As Short
End Function' hdesc : void* in/out
' iRecord : SHORT
' szName : BYTE* optional, out
' cbNameMax : SHORT
' pcbName : SHORT* optional, out
' pfType : SHORT* optional, out
' pfSubType : SHORT* optional, out
' pLength : INT* optional, out
' pPrecision : SHORT* optional, out
' pScale : SHORT* optional, out
' pNullable : SHORT* optional, out
Declare PtrSafe Function SQLGetDescRecA Lib "odbc32" ( _
ByVal hdesc As LongPtr, _
ByVal iRecord As Integer, _
ByVal szName As LongPtr, _
ByVal cbNameMax As Integer, _
ByVal pcbName As LongPtr, _
ByVal pfType As LongPtr, _
ByVal pfSubType As LongPtr, _
ByVal pLength As LongPtr, _
ByVal pPrecision As LongPtr, _
ByVal pScale As LongPtr, _
ByVal pNullable As LongPtr) As Integer
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SQLGetDescRecA = ctypes.windll.odbc32.SQLGetDescRecA
SQLGetDescRecA.restype = ctypes.c_short
SQLGetDescRecA.argtypes = [
ctypes.POINTER(None), # hdesc : void* in/out
ctypes.c_short, # iRecord : SHORT
ctypes.POINTER(ctypes.c_ubyte), # szName : BYTE* optional, out
ctypes.c_short, # cbNameMax : SHORT
ctypes.POINTER(ctypes.c_short), # pcbName : SHORT* optional, out
ctypes.POINTER(ctypes.c_short), # pfType : SHORT* optional, out
ctypes.POINTER(ctypes.c_short), # pfSubType : SHORT* optional, out
ctypes.POINTER(ctypes.c_int), # pLength : INT* optional, out
ctypes.POINTER(ctypes.c_short), # pPrecision : SHORT* optional, out
ctypes.POINTER(ctypes.c_short), # pScale : SHORT* optional, out
ctypes.POINTER(ctypes.c_short), # pNullable : SHORT* optional, out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ODBC32.dll')
SQLGetDescRecA = Fiddle::Function.new(
lib['SQLGetDescRecA'],
[
Fiddle::TYPE_VOIDP, # hdesc : void* in/out
Fiddle::TYPE_SHORT, # iRecord : SHORT
Fiddle::TYPE_VOIDP, # szName : BYTE* optional, out
Fiddle::TYPE_SHORT, # cbNameMax : SHORT
Fiddle::TYPE_VOIDP, # pcbName : SHORT* optional, out
Fiddle::TYPE_VOIDP, # pfType : SHORT* optional, out
Fiddle::TYPE_VOIDP, # pfSubType : SHORT* optional, out
Fiddle::TYPE_VOIDP, # pLength : INT* optional, out
Fiddle::TYPE_VOIDP, # pPrecision : SHORT* optional, out
Fiddle::TYPE_VOIDP, # pScale : SHORT* optional, out
Fiddle::TYPE_VOIDP, # pNullable : SHORT* optional, out
],
Fiddle::TYPE_SHORT)#[link(name = "odbc32")]
extern "system" {
fn SQLGetDescRecA(
hdesc: *mut (), // void* in/out
iRecord: i16, // SHORT
szName: *mut u8, // BYTE* optional, out
cbNameMax: i16, // SHORT
pcbName: *mut i16, // SHORT* optional, out
pfType: *mut i16, // SHORT* optional, out
pfSubType: *mut i16, // SHORT* optional, out
pLength: *mut i32, // INT* optional, out
pPrecision: *mut i16, // SHORT* optional, out
pScale: *mut i16, // SHORT* optional, out
pNullable: *mut i16 // SHORT* optional, out
) -> i16;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ODBC32.dll", CharSet = CharSet.Ansi)]
public static extern short SQLGetDescRecA(IntPtr hdesc, short iRecord, IntPtr szName, short cbNameMax, IntPtr pcbName, IntPtr pfType, IntPtr pfSubType, IntPtr pLength, IntPtr pPrecision, IntPtr pScale, IntPtr pNullable);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ODBC32_SQLGetDescRecA' -Namespace Win32 -PassThru
# $api::SQLGetDescRecA(hdesc, iRecord, szName, cbNameMax, pcbName, pfType, pfSubType, pLength, pPrecision, pScale, pNullable)#uselib "ODBC32.dll"
#func global SQLGetDescRecA "SQLGetDescRecA" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; SQLGetDescRecA hdesc, iRecord, varptr(szName), cbNameMax, varptr(pcbName), varptr(pfType), varptr(pfSubType), varptr(pLength), varptr(pPrecision), varptr(pScale), varptr(pNullable) ; 戻り値は stat
; hdesc : void* in/out -> "sptr"
; iRecord : SHORT -> "sptr"
; szName : BYTE* optional, out -> "sptr"
; cbNameMax : SHORT -> "sptr"
; pcbName : SHORT* optional, out -> "sptr"
; pfType : SHORT* optional, out -> "sptr"
; pfSubType : SHORT* optional, out -> "sptr"
; pLength : INT* optional, out -> "sptr"
; pPrecision : SHORT* optional, out -> "sptr"
; pScale : SHORT* optional, out -> "sptr"
; pNullable : SHORT* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "ODBC32.dll" #cfunc global SQLGetDescRecA "SQLGetDescRecA" sptr, int, var, int, var, var, var, var, var, var, var ; res = SQLGetDescRecA(hdesc, iRecord, szName, cbNameMax, pcbName, pfType, pfSubType, pLength, pPrecision, pScale, pNullable) ; hdesc : void* in/out -> "sptr" ; iRecord : SHORT -> "int" ; szName : BYTE* optional, out -> "var" ; cbNameMax : SHORT -> "int" ; pcbName : SHORT* optional, out -> "var" ; pfType : SHORT* optional, out -> "var" ; pfSubType : SHORT* optional, out -> "var" ; pLength : INT* optional, out -> "var" ; pPrecision : SHORT* optional, out -> "var" ; pScale : SHORT* optional, out -> "var" ; pNullable : SHORT* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ODBC32.dll" #cfunc global SQLGetDescRecA "SQLGetDescRecA" sptr, int, sptr, int, sptr, sptr, sptr, sptr, sptr, sptr, sptr ; res = SQLGetDescRecA(hdesc, iRecord, varptr(szName), cbNameMax, varptr(pcbName), varptr(pfType), varptr(pfSubType), varptr(pLength), varptr(pPrecision), varptr(pScale), varptr(pNullable)) ; hdesc : void* in/out -> "sptr" ; iRecord : SHORT -> "int" ; szName : BYTE* optional, out -> "sptr" ; cbNameMax : SHORT -> "int" ; pcbName : SHORT* optional, out -> "sptr" ; pfType : SHORT* optional, out -> "sptr" ; pfSubType : SHORT* optional, out -> "sptr" ; pLength : INT* optional, out -> "sptr" ; pPrecision : SHORT* optional, out -> "sptr" ; pScale : SHORT* optional, out -> "sptr" ; pNullable : SHORT* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; SHORT SQLGetDescRecA(void* hdesc, SHORT iRecord, BYTE* szName, SHORT cbNameMax, SHORT* pcbName, SHORT* pfType, SHORT* pfSubType, INT* pLength, SHORT* pPrecision, SHORT* pScale, SHORT* pNullable) #uselib "ODBC32.dll" #cfunc global SQLGetDescRecA "SQLGetDescRecA" intptr, int, var, int, var, var, var, var, var, var, var ; res = SQLGetDescRecA(hdesc, iRecord, szName, cbNameMax, pcbName, pfType, pfSubType, pLength, pPrecision, pScale, pNullable) ; hdesc : void* in/out -> "intptr" ; iRecord : SHORT -> "int" ; szName : BYTE* optional, out -> "var" ; cbNameMax : SHORT -> "int" ; pcbName : SHORT* optional, out -> "var" ; pfType : SHORT* optional, out -> "var" ; pfSubType : SHORT* optional, out -> "var" ; pLength : INT* optional, out -> "var" ; pPrecision : SHORT* optional, out -> "var" ; pScale : SHORT* optional, out -> "var" ; pNullable : SHORT* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; SHORT SQLGetDescRecA(void* hdesc, SHORT iRecord, BYTE* szName, SHORT cbNameMax, SHORT* pcbName, SHORT* pfType, SHORT* pfSubType, INT* pLength, SHORT* pPrecision, SHORT* pScale, SHORT* pNullable) #uselib "ODBC32.dll" #cfunc global SQLGetDescRecA "SQLGetDescRecA" intptr, int, intptr, int, intptr, intptr, intptr, intptr, intptr, intptr, intptr ; res = SQLGetDescRecA(hdesc, iRecord, varptr(szName), cbNameMax, varptr(pcbName), varptr(pfType), varptr(pfSubType), varptr(pLength), varptr(pPrecision), varptr(pScale), varptr(pNullable)) ; hdesc : void* in/out -> "intptr" ; iRecord : SHORT -> "int" ; szName : BYTE* optional, out -> "intptr" ; cbNameMax : SHORT -> "int" ; pcbName : SHORT* optional, out -> "intptr" ; pfType : SHORT* optional, out -> "intptr" ; pfSubType : SHORT* optional, out -> "intptr" ; pLength : INT* optional, out -> "intptr" ; pPrecision : SHORT* optional, out -> "intptr" ; pScale : SHORT* optional, out -> "intptr" ; pNullable : SHORT* optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
odbc32 = windows.NewLazySystemDLL("ODBC32.dll")
procSQLGetDescRecA = odbc32.NewProc("SQLGetDescRecA")
)
// hdesc (void* in/out), iRecord (SHORT), szName (BYTE* optional, out), cbNameMax (SHORT), pcbName (SHORT* optional, out), pfType (SHORT* optional, out), pfSubType (SHORT* optional, out), pLength (INT* optional, out), pPrecision (SHORT* optional, out), pScale (SHORT* optional, out), pNullable (SHORT* optional, out)
r1, _, err := procSQLGetDescRecA.Call(
uintptr(hdesc),
uintptr(iRecord),
uintptr(szName),
uintptr(cbNameMax),
uintptr(pcbName),
uintptr(pfType),
uintptr(pfSubType),
uintptr(pLength),
uintptr(pPrecision),
uintptr(pScale),
uintptr(pNullable),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // SHORTfunction SQLGetDescRecA(
hdesc: Pointer; // void* in/out
iRecord: Smallint; // SHORT
szName: Pointer; // BYTE* optional, out
cbNameMax: Smallint; // SHORT
pcbName: Pointer; // SHORT* optional, out
pfType: Pointer; // SHORT* optional, out
pfSubType: Pointer; // SHORT* optional, out
pLength: Pointer; // INT* optional, out
pPrecision: Pointer; // SHORT* optional, out
pScale: Pointer; // SHORT* optional, out
pNullable: Pointer // SHORT* optional, out
): Smallint; stdcall;
external 'ODBC32.dll' name 'SQLGetDescRecA';result := DllCall("ODBC32\SQLGetDescRecA"
, "Ptr", hdesc ; void* in/out
, "Short", iRecord ; SHORT
, "Ptr", szName ; BYTE* optional, out
, "Short", cbNameMax ; SHORT
, "Ptr", pcbName ; SHORT* optional, out
, "Ptr", pfType ; SHORT* optional, out
, "Ptr", pfSubType ; SHORT* optional, out
, "Ptr", pLength ; INT* optional, out
, "Ptr", pPrecision ; SHORT* optional, out
, "Ptr", pScale ; SHORT* optional, out
, "Ptr", pNullable ; SHORT* optional, out
, "Short") ; return: SHORT●SQLGetDescRecA(hdesc, iRecord, szName, cbNameMax, pcbName, pfType, pfSubType, pLength, pPrecision, pScale, pNullable) = DLL("ODBC32.dll", "int SQLGetDescRecA(void*, int, void*, int, void*, void*, void*, void*, void*, void*, void*)")
# 呼び出し: SQLGetDescRecA(hdesc, iRecord, szName, cbNameMax, pcbName, pfType, pfSubType, pLength, pPrecision, pScale, pNullable)
# hdesc : void* in/out -> "void*"
# iRecord : SHORT -> "int"
# szName : BYTE* optional, out -> "void*"
# cbNameMax : SHORT -> "int"
# pcbName : SHORT* optional, out -> "void*"
# pfType : SHORT* optional, out -> "void*"
# pfSubType : SHORT* optional, out -> "void*"
# pLength : INT* optional, out -> "void*"
# pPrecision : SHORT* optional, out -> "void*"
# pScale : SHORT* optional, out -> "void*"
# pNullable : SHORT* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "odbc32" fn SQLGetDescRecA(
hdesc: ?*anyopaque, // void* in/out
iRecord: i16, // SHORT
szName: [*c]u8, // BYTE* optional, out
cbNameMax: i16, // SHORT
pcbName: [*c]i16, // SHORT* optional, out
pfType: [*c]i16, // SHORT* optional, out
pfSubType: [*c]i16, // SHORT* optional, out
pLength: [*c]i32, // INT* optional, out
pPrecision: [*c]i16, // SHORT* optional, out
pScale: [*c]i16, // SHORT* optional, out
pNullable: [*c]i16 // SHORT* optional, out
) callconv(std.os.windows.WINAPI) i16;proc SQLGetDescRecA(
hdesc: pointer, # void* in/out
iRecord: int16, # SHORT
szName: ptr uint8, # BYTE* optional, out
cbNameMax: int16, # SHORT
pcbName: ptr int16, # SHORT* optional, out
pfType: ptr int16, # SHORT* optional, out
pfSubType: ptr int16, # SHORT* optional, out
pLength: ptr int32, # INT* optional, out
pPrecision: ptr int16, # SHORT* optional, out
pScale: ptr int16, # SHORT* optional, out
pNullable: ptr int16 # SHORT* optional, out
): int16 {.importc: "SQLGetDescRecA", stdcall, dynlib: "ODBC32.dll".}pragma(lib, "odbc32");
extern(Windows)
short SQLGetDescRecA(
void* hdesc, // void* in/out
short iRecord, // SHORT
ubyte* szName, // BYTE* optional, out
short cbNameMax, // SHORT
short* pcbName, // SHORT* optional, out
short* pfType, // SHORT* optional, out
short* pfSubType, // SHORT* optional, out
int* pLength, // INT* optional, out
short* pPrecision, // SHORT* optional, out
short* pScale, // SHORT* optional, out
short* pNullable // SHORT* optional, out
);ccall((:SQLGetDescRecA, "ODBC32.dll"), stdcall, Int16,
(Ptr{Cvoid}, Int16, Ptr{UInt8}, Int16, Ptr{Int16}, Ptr{Int16}, Ptr{Int16}, Ptr{Int32}, Ptr{Int16}, Ptr{Int16}, Ptr{Int16}),
hdesc, iRecord, szName, cbNameMax, pcbName, pfType, pfSubType, pLength, pPrecision, pScale, pNullable)
# hdesc : void* in/out -> Ptr{Cvoid}
# iRecord : SHORT -> Int16
# szName : BYTE* optional, out -> Ptr{UInt8}
# cbNameMax : SHORT -> Int16
# pcbName : SHORT* optional, out -> Ptr{Int16}
# pfType : SHORT* optional, out -> Ptr{Int16}
# pfSubType : SHORT* optional, out -> Ptr{Int16}
# pLength : INT* optional, out -> Ptr{Int32}
# pPrecision : SHORT* optional, out -> Ptr{Int16}
# pScale : SHORT* optional, out -> Ptr{Int16}
# pNullable : SHORT* optional, out -> Ptr{Int16}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int16_t SQLGetDescRecA(
void* hdesc,
int16_t iRecord,
uint8_t* szName,
int16_t cbNameMax,
int16_t* pcbName,
int16_t* pfType,
int16_t* pfSubType,
int32_t* pLength,
int16_t* pPrecision,
int16_t* pScale,
int16_t* pNullable);
]]
local odbc32 = ffi.load("odbc32")
-- odbc32.SQLGetDescRecA(hdesc, iRecord, szName, cbNameMax, pcbName, pfType, pfSubType, pLength, pPrecision, pScale, pNullable)
-- hdesc : void* in/out
-- iRecord : SHORT
-- szName : BYTE* optional, out
-- cbNameMax : SHORT
-- pcbName : SHORT* optional, out
-- pfType : SHORT* optional, out
-- pfSubType : SHORT* optional, out
-- pLength : INT* optional, out
-- pPrecision : SHORT* optional, out
-- pScale : SHORT* optional, out
-- pNullable : SHORT* optional, out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('ODBC32.dll');
const SQLGetDescRecA = lib.func('__stdcall', 'SQLGetDescRecA', 'int16_t', ['void *', 'int16_t', 'uint8_t *', 'int16_t', 'int16_t *', 'int16_t *', 'int16_t *', 'int32_t *', 'int16_t *', 'int16_t *', 'int16_t *']);
// SQLGetDescRecA(hdesc, iRecord, szName, cbNameMax, pcbName, pfType, pfSubType, pLength, pPrecision, pScale, pNullable)
// hdesc : void* in/out -> 'void *'
// iRecord : SHORT -> 'int16_t'
// szName : BYTE* optional, out -> 'uint8_t *'
// cbNameMax : SHORT -> 'int16_t'
// pcbName : SHORT* optional, out -> 'int16_t *'
// pfType : SHORT* optional, out -> 'int16_t *'
// pfSubType : SHORT* optional, out -> 'int16_t *'
// pLength : INT* optional, out -> 'int32_t *'
// pPrecision : SHORT* optional, out -> 'int16_t *'
// pScale : SHORT* optional, out -> 'int16_t *'
// pNullable : SHORT* optional, out -> 'int16_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("ODBC32.dll", {
SQLGetDescRecA: { parameters: ["pointer", "i16", "pointer", "i16", "pointer", "pointer", "pointer", "pointer", "pointer", "pointer", "pointer"], result: "i16" },
});
// lib.symbols.SQLGetDescRecA(hdesc, iRecord, szName, cbNameMax, pcbName, pfType, pfSubType, pLength, pPrecision, pScale, pNullable)
// hdesc : void* in/out -> "pointer"
// iRecord : SHORT -> "i16"
// szName : BYTE* optional, out -> "pointer"
// cbNameMax : SHORT -> "i16"
// pcbName : SHORT* optional, out -> "pointer"
// pfType : SHORT* optional, out -> "pointer"
// pfSubType : SHORT* optional, out -> "pointer"
// pLength : INT* optional, out -> "pointer"
// pPrecision : SHORT* optional, out -> "pointer"
// pScale : SHORT* optional, out -> "pointer"
// pNullable : SHORT* optional, out -> "pointer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int16_t SQLGetDescRecA(
void* hdesc,
int16_t iRecord,
uint8_t* szName,
int16_t cbNameMax,
int16_t* pcbName,
int16_t* pfType,
int16_t* pfSubType,
int32_t* pLength,
int16_t* pPrecision,
int16_t* pScale,
int16_t* pNullable);
C, "ODBC32.dll");
// $ffi->SQLGetDescRecA(hdesc, iRecord, szName, cbNameMax, pcbName, pfType, pfSubType, pLength, pPrecision, pScale, pNullable);
// hdesc : void* in/out
// iRecord : SHORT
// szName : BYTE* optional, out
// cbNameMax : SHORT
// pcbName : SHORT* optional, out
// pfType : SHORT* optional, out
// pfSubType : SHORT* optional, out
// pLength : INT* optional, out
// pPrecision : SHORT* optional, out
// pScale : SHORT* optional, out
// pNullable : SHORT* optional, out
// 構造体/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 SQLGetDescRecA(
Pointer hdesc, // void* in/out
short iRecord, // SHORT
byte[] szName, // BYTE* optional, out
short cbNameMax, // SHORT
ShortByReference pcbName, // SHORT* optional, out
ShortByReference pfType, // SHORT* optional, out
ShortByReference pfSubType, // SHORT* optional, out
IntByReference pLength, // INT* optional, out
ShortByReference pPrecision, // SHORT* optional, out
ShortByReference pScale, // SHORT* optional, out
ShortByReference pNullable // SHORT* optional, out
);
}@[Link("odbc32")]
lib LibODBC32
fun SQLGetDescRecA = SQLGetDescRecA(
hdesc : Void*, # void* in/out
iRecord : Int16, # SHORT
szName : UInt8*, # BYTE* optional, out
cbNameMax : Int16, # SHORT
pcbName : Int16*, # SHORT* optional, out
pfType : Int16*, # SHORT* optional, out
pfSubType : Int16*, # SHORT* optional, out
pLength : Int32*, # INT* optional, out
pPrecision : Int16*, # SHORT* optional, out
pScale : Int16*, # SHORT* optional, out
pNullable : Int16* # SHORT* optional, out
) : Int16
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef SQLGetDescRecANative = Int16 Function(Pointer<Void>, Int16, Pointer<Uint8>, Int16, Pointer<Int16>, Pointer<Int16>, Pointer<Int16>, Pointer<Int32>, Pointer<Int16>, Pointer<Int16>, Pointer<Int16>);
typedef SQLGetDescRecADart = int Function(Pointer<Void>, int, Pointer<Uint8>, int, Pointer<Int16>, Pointer<Int16>, Pointer<Int16>, Pointer<Int32>, Pointer<Int16>, Pointer<Int16>, Pointer<Int16>);
final SQLGetDescRecA = DynamicLibrary.open('ODBC32.dll')
.lookupFunction<SQLGetDescRecANative, SQLGetDescRecADart>('SQLGetDescRecA');
// hdesc : void* in/out -> Pointer<Void>
// iRecord : SHORT -> Int16
// szName : BYTE* optional, out -> Pointer<Uint8>
// cbNameMax : SHORT -> Int16
// pcbName : SHORT* optional, out -> Pointer<Int16>
// pfType : SHORT* optional, out -> Pointer<Int16>
// pfSubType : SHORT* optional, out -> Pointer<Int16>
// pLength : INT* optional, out -> Pointer<Int32>
// pPrecision : SHORT* optional, out -> Pointer<Int16>
// pScale : SHORT* optional, out -> Pointer<Int16>
// pNullable : SHORT* optional, out -> Pointer<Int16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SQLGetDescRecA(
hdesc: Pointer; // void* in/out
iRecord: Smallint; // SHORT
szName: Pointer; // BYTE* optional, out
cbNameMax: Smallint; // SHORT
pcbName: Pointer; // SHORT* optional, out
pfType: Pointer; // SHORT* optional, out
pfSubType: Pointer; // SHORT* optional, out
pLength: Pointer; // INT* optional, out
pPrecision: Pointer; // SHORT* optional, out
pScale: Pointer; // SHORT* optional, out
pNullable: Pointer // SHORT* optional, out
): Smallint; stdcall;
external 'ODBC32.dll' name 'SQLGetDescRecA';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SQLGetDescRecA"
c_SQLGetDescRecA :: Ptr () -> Int16 -> Ptr Word8 -> Int16 -> Ptr Int16 -> Ptr Int16 -> Ptr Int16 -> Ptr Int32 -> Ptr Int16 -> Ptr Int16 -> Ptr Int16 -> IO Int16
-- hdesc : void* in/out -> Ptr ()
-- iRecord : SHORT -> Int16
-- szName : BYTE* optional, out -> Ptr Word8
-- cbNameMax : SHORT -> Int16
-- pcbName : SHORT* optional, out -> Ptr Int16
-- pfType : SHORT* optional, out -> Ptr Int16
-- pfSubType : SHORT* optional, out -> Ptr Int16
-- pLength : INT* optional, out -> Ptr Int32
-- pPrecision : SHORT* optional, out -> Ptr Int16
-- pScale : SHORT* optional, out -> Ptr Int16
-- pNullable : SHORT* optional, out -> Ptr Int16
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let sqlgetdescreca =
foreign "SQLGetDescRecA"
((ptr void) @-> int16_t @-> (ptr uint8_t) @-> int16_t @-> (ptr int16_t) @-> (ptr int16_t) @-> (ptr int16_t) @-> (ptr int32_t) @-> (ptr int16_t) @-> (ptr int16_t) @-> (ptr int16_t) @-> returning int16_t)
(* hdesc : void* in/out -> (ptr void) *)
(* iRecord : SHORT -> int16_t *)
(* szName : BYTE* optional, out -> (ptr uint8_t) *)
(* cbNameMax : SHORT -> int16_t *)
(* pcbName : SHORT* optional, out -> (ptr int16_t) *)
(* pfType : SHORT* optional, out -> (ptr int16_t) *)
(* pfSubType : SHORT* optional, out -> (ptr int16_t) *)
(* pLength : INT* optional, out -> (ptr int32_t) *)
(* pPrecision : SHORT* optional, out -> (ptr int16_t) *)
(* pScale : SHORT* optional, out -> (ptr int16_t) *)
(* pNullable : SHORT* optional, out -> (ptr int16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library odbc32 (t "ODBC32.dll"))
(cffi:use-foreign-library odbc32)
(cffi:defcfun ("SQLGetDescRecA" sqlget-desc-rec-a :convention :stdcall) :int16
(hdesc :pointer) ; void* in/out
(i-record :int16) ; SHORT
(sz-name :pointer) ; BYTE* optional, out
(cb-name-max :int16) ; SHORT
(pcb-name :pointer) ; SHORT* optional, out
(pf-type :pointer) ; SHORT* optional, out
(pf-sub-type :pointer) ; SHORT* optional, out
(p-length :pointer) ; INT* optional, out
(p-precision :pointer) ; SHORT* optional, out
(p-scale :pointer) ; SHORT* optional, out
(p-nullable :pointer)) ; SHORT* optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SQLGetDescRecA = Win32::API::More->new('ODBC32',
'short SQLGetDescRecA(LPVOID hdesc, short iRecord, LPVOID szName, short cbNameMax, LPVOID pcbName, LPVOID pfType, LPVOID pfSubType, LPVOID pLength, LPVOID pPrecision, LPVOID pScale, LPVOID pNullable)');
# my $ret = $SQLGetDescRecA->Call($hdesc, $iRecord, $szName, $cbNameMax, $pcbName, $pfType, $pfSubType, $pLength, $pPrecision, $pScale, $pNullable);
# hdesc : void* in/out -> LPVOID
# iRecord : SHORT -> short
# szName : BYTE* optional, out -> LPVOID
# cbNameMax : SHORT -> short
# pcbName : SHORT* optional, out -> LPVOID
# pfType : SHORT* optional, out -> LPVOID
# pfSubType : SHORT* optional, out -> LPVOID
# pLength : INT* optional, out -> LPVOID
# pPrecision : SHORT* optional, out -> LPVOID
# pScale : SHORT* optional, out -> LPVOID
# pNullable : SHORT* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
文字セット違い
- f SQLGetDescRecW (Unicode版) — 記述子レコードの複数フィールド値をまとめて取得する(Unicode)。