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