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