Win32 API 日本語リファレンス
ホームSystem.Search › SQLError

SQLError

関数
直前のODBC関数の診断エラー情報を取得する。
DLLODBC32.dll文字セットANSI (-A)呼出規約winapi

シグネチャ

// ODBC32.dll  (ANSI / -A)
#include <windows.h>

SHORT SQLError(
    void* EnvironmentHandle,
    void* ConnectionHandle,
    void* StatementHandle,
    BYTE* Sqlstate,
    INT* NativeError,   // optional
    BYTE* MessageText,   // optional
    SHORT BufferLength,
    SHORT* TextLength   // optional
);

パラメーター

名前方向説明
EnvironmentHandlevoid*inout診断情報を取得する環境ハンドル(HENV)。未使用時はNULL可。
ConnectionHandlevoid*inout診断情報を取得する接続ハンドル(HDBC)。未使用時はNULL可。
StatementHandlevoid*inout診断情報を取得するステートメントハンドル(HSTMT)。未使用時はNULL可。
SqlstateBYTE*out5文字のSQLSTATE文字列を受け取るバッファへのポインタ。
NativeErrorINT*outoptionalドライバ固有のネイティブエラーコードを受け取るポインタ。
MessageTextBYTE*outoptionalエラーメッセージ文字列を受け取るバッファへのポインタ。
BufferLengthSHORTinMessageTextバッファのバイト長。
TextLengthSHORT*outoptionalメッセージの実際の長さを受け取るポインタ。

戻り値の型: SHORT

各言語での呼び出し定義

// ODBC32.dll  (ANSI / -A)
#include <windows.h>

SHORT SQLError(
    void* EnvironmentHandle,
    void* ConnectionHandle,
    void* StatementHandle,
    BYTE* Sqlstate,
    INT* NativeError,   // optional
    BYTE* MessageText,   // optional
    SHORT BufferLength,
    SHORT* TextLength   // optional
);
[DllImport("ODBC32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern short SQLError(
    IntPtr EnvironmentHandle,   // void* in/out
    IntPtr ConnectionHandle,   // void* in/out
    IntPtr StatementHandle,   // void* in/out
    IntPtr Sqlstate,   // BYTE* out
    IntPtr NativeError,   // INT* optional, out
    IntPtr MessageText,   // BYTE* optional, out
    short BufferLength,   // SHORT
    IntPtr TextLength   // SHORT* optional, out
);
<DllImport("ODBC32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function SQLError(
    EnvironmentHandle As IntPtr,   ' void* in/out
    ConnectionHandle As IntPtr,   ' void* in/out
    StatementHandle As IntPtr,   ' void* in/out
    Sqlstate As IntPtr,   ' BYTE* out
    NativeError As IntPtr,   ' INT* optional, out
    MessageText As IntPtr,   ' BYTE* optional, out
    BufferLength As Short,   ' SHORT
    TextLength As IntPtr   ' SHORT* optional, out
) As Short
End Function
' EnvironmentHandle : void* in/out
' ConnectionHandle : void* in/out
' StatementHandle : void* in/out
' Sqlstate : BYTE* out
' NativeError : INT* optional, out
' MessageText : BYTE* optional, out
' BufferLength : SHORT
' TextLength : SHORT* optional, out
Declare PtrSafe Function SQLError Lib "odbc32" ( _
    ByVal EnvironmentHandle As LongPtr, _
    ByVal ConnectionHandle As LongPtr, _
    ByVal StatementHandle As LongPtr, _
    ByVal Sqlstate As LongPtr, _
    ByVal NativeError As LongPtr, _
    ByVal MessageText As LongPtr, _
    ByVal BufferLength As Integer, _
    ByVal TextLength As LongPtr) As Integer
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SQLError = ctypes.windll.odbc32.SQLError
SQLError.restype = ctypes.c_short
SQLError.argtypes = [
    ctypes.POINTER(None),  # EnvironmentHandle : void* in/out
    ctypes.POINTER(None),  # ConnectionHandle : void* in/out
    ctypes.POINTER(None),  # StatementHandle : void* in/out
    ctypes.POINTER(ctypes.c_ubyte),  # Sqlstate : BYTE* out
    ctypes.POINTER(ctypes.c_int),  # NativeError : INT* optional, out
    ctypes.POINTER(ctypes.c_ubyte),  # MessageText : BYTE* optional, out
    ctypes.c_short,  # BufferLength : SHORT
    ctypes.POINTER(ctypes.c_short),  # TextLength : SHORT* optional, out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('ODBC32.dll')
SQLError = Fiddle::Function.new(
  lib['SQLError'],
  [
    Fiddle::TYPE_VOIDP,  # EnvironmentHandle : void* in/out
    Fiddle::TYPE_VOIDP,  # ConnectionHandle : void* in/out
    Fiddle::TYPE_VOIDP,  # StatementHandle : void* in/out
    Fiddle::TYPE_VOIDP,  # Sqlstate : BYTE* out
    Fiddle::TYPE_VOIDP,  # NativeError : INT* optional, out
    Fiddle::TYPE_VOIDP,  # MessageText : BYTE* optional, out
    Fiddle::TYPE_SHORT,  # BufferLength : SHORT
    Fiddle::TYPE_VOIDP,  # TextLength : SHORT* optional, out
  ],
  Fiddle::TYPE_SHORT)
#[link(name = "odbc32")]
extern "system" {
    fn SQLError(
        EnvironmentHandle: *mut (),  // void* in/out
        ConnectionHandle: *mut (),  // void* in/out
        StatementHandle: *mut (),  // void* in/out
        Sqlstate: *mut u8,  // BYTE* out
        NativeError: *mut i32,  // INT* optional, out
        MessageText: *mut u8,  // BYTE* optional, out
        BufferLength: i16,  // SHORT
        TextLength: *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 SQLError(IntPtr EnvironmentHandle, IntPtr ConnectionHandle, IntPtr StatementHandle, IntPtr Sqlstate, IntPtr NativeError, IntPtr MessageText, short BufferLength, IntPtr TextLength);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ODBC32_SQLError' -Namespace Win32 -PassThru
# $api::SQLError(EnvironmentHandle, ConnectionHandle, StatementHandle, Sqlstate, NativeError, MessageText, BufferLength, TextLength)
#uselib "ODBC32.dll"
#func global SQLError "SQLError" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; SQLError EnvironmentHandle, ConnectionHandle, StatementHandle, varptr(Sqlstate), varptr(NativeError), varptr(MessageText), BufferLength, varptr(TextLength)   ; 戻り値は stat
; EnvironmentHandle : void* in/out -> "sptr"
; ConnectionHandle : void* in/out -> "sptr"
; StatementHandle : void* in/out -> "sptr"
; Sqlstate : BYTE* out -> "sptr"
; NativeError : INT* optional, out -> "sptr"
; MessageText : BYTE* optional, out -> "sptr"
; BufferLength : SHORT -> "sptr"
; TextLength : SHORT* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "ODBC32.dll"
#cfunc global SQLError "SQLError" sptr, sptr, sptr, var, var, var, int, var
; res = SQLError(EnvironmentHandle, ConnectionHandle, StatementHandle, Sqlstate, NativeError, MessageText, BufferLength, TextLength)
; EnvironmentHandle : void* in/out -> "sptr"
; ConnectionHandle : void* in/out -> "sptr"
; StatementHandle : void* in/out -> "sptr"
; Sqlstate : BYTE* out -> "var"
; NativeError : INT* optional, out -> "var"
; MessageText : BYTE* optional, out -> "var"
; BufferLength : SHORT -> "int"
; TextLength : SHORT* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; SHORT SQLError(void* EnvironmentHandle, void* ConnectionHandle, void* StatementHandle, BYTE* Sqlstate, INT* NativeError, BYTE* MessageText, SHORT BufferLength, SHORT* TextLength)
#uselib "ODBC32.dll"
#cfunc global SQLError "SQLError" intptr, intptr, intptr, var, var, var, int, var
; res = SQLError(EnvironmentHandle, ConnectionHandle, StatementHandle, Sqlstate, NativeError, MessageText, BufferLength, TextLength)
; EnvironmentHandle : void* in/out -> "intptr"
; ConnectionHandle : void* in/out -> "intptr"
; StatementHandle : void* in/out -> "intptr"
; Sqlstate : BYTE* out -> "var"
; NativeError : INT* optional, out -> "var"
; MessageText : BYTE* optional, out -> "var"
; BufferLength : SHORT -> "int"
; TextLength : SHORT* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	odbc32 = windows.NewLazySystemDLL("ODBC32.dll")
	procSQLError = odbc32.NewProc("SQLError")
)

// EnvironmentHandle (void* in/out), ConnectionHandle (void* in/out), StatementHandle (void* in/out), Sqlstate (BYTE* out), NativeError (INT* optional, out), MessageText (BYTE* optional, out), BufferLength (SHORT), TextLength (SHORT* optional, out)
r1, _, err := procSQLError.Call(
	uintptr(EnvironmentHandle),
	uintptr(ConnectionHandle),
	uintptr(StatementHandle),
	uintptr(Sqlstate),
	uintptr(NativeError),
	uintptr(MessageText),
	uintptr(BufferLength),
	uintptr(TextLength),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // SHORT
function SQLError(
  EnvironmentHandle: Pointer;   // void* in/out
  ConnectionHandle: Pointer;   // void* in/out
  StatementHandle: Pointer;   // void* in/out
  Sqlstate: Pointer;   // BYTE* out
  NativeError: Pointer;   // INT* optional, out
  MessageText: Pointer;   // BYTE* optional, out
  BufferLength: Smallint;   // SHORT
  TextLength: Pointer   // SHORT* optional, out
): Smallint; stdcall;
  external 'ODBC32.dll' name 'SQLError';
result := DllCall("ODBC32\SQLError"
    , "Ptr", EnvironmentHandle   ; void* in/out
    , "Ptr", ConnectionHandle   ; void* in/out
    , "Ptr", StatementHandle   ; void* in/out
    , "Ptr", Sqlstate   ; BYTE* out
    , "Ptr", NativeError   ; INT* optional, out
    , "Ptr", MessageText   ; BYTE* optional, out
    , "Short", BufferLength   ; SHORT
    , "Ptr", TextLength   ; SHORT* optional, out
    , "Short")   ; return: SHORT
●SQLError(EnvironmentHandle, ConnectionHandle, StatementHandle, Sqlstate, NativeError, MessageText, BufferLength, TextLength) = DLL("ODBC32.dll", "int SQLError(void*, void*, void*, void*, void*, void*, int, void*)")
# 呼び出し: SQLError(EnvironmentHandle, ConnectionHandle, StatementHandle, Sqlstate, NativeError, MessageText, BufferLength, TextLength)
# EnvironmentHandle : void* in/out -> "void*"
# ConnectionHandle : void* in/out -> "void*"
# StatementHandle : void* in/out -> "void*"
# Sqlstate : BYTE* out -> "void*"
# NativeError : INT* optional, out -> "void*"
# MessageText : BYTE* optional, out -> "void*"
# BufferLength : SHORT -> "int"
# TextLength : SHORT* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "odbc32" fn SQLError(
    EnvironmentHandle: ?*anyopaque, // void* in/out
    ConnectionHandle: ?*anyopaque, // void* in/out
    StatementHandle: ?*anyopaque, // void* in/out
    Sqlstate: [*c]u8, // BYTE* out
    NativeError: [*c]i32, // INT* optional, out
    MessageText: [*c]u8, // BYTE* optional, out
    BufferLength: i16, // SHORT
    TextLength: [*c]i16 // SHORT* optional, out
) callconv(std.os.windows.WINAPI) i16;
proc SQLError(
    EnvironmentHandle: pointer,  # void* in/out
    ConnectionHandle: pointer,  # void* in/out
    StatementHandle: pointer,  # void* in/out
    Sqlstate: ptr uint8,  # BYTE* out
    NativeError: ptr int32,  # INT* optional, out
    MessageText: ptr uint8,  # BYTE* optional, out
    BufferLength: int16,  # SHORT
    TextLength: ptr int16  # SHORT* optional, out
): int16 {.importc: "SQLError", stdcall, dynlib: "ODBC32.dll".}
pragma(lib, "odbc32");
extern(Windows)
short SQLError(
    void* EnvironmentHandle,   // void* in/out
    void* ConnectionHandle,   // void* in/out
    void* StatementHandle,   // void* in/out
    ubyte* Sqlstate,   // BYTE* out
    int* NativeError,   // INT* optional, out
    ubyte* MessageText,   // BYTE* optional, out
    short BufferLength,   // SHORT
    short* TextLength   // SHORT* optional, out
);
ccall((:SQLError, "ODBC32.dll"), stdcall, Int16,
      (Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{UInt8}, Ptr{Int32}, Ptr{UInt8}, Int16, Ptr{Int16}),
      EnvironmentHandle, ConnectionHandle, StatementHandle, Sqlstate, NativeError, MessageText, BufferLength, TextLength)
# EnvironmentHandle : void* in/out -> Ptr{Cvoid}
# ConnectionHandle : void* in/out -> Ptr{Cvoid}
# StatementHandle : void* in/out -> Ptr{Cvoid}
# Sqlstate : BYTE* out -> Ptr{UInt8}
# NativeError : INT* optional, out -> Ptr{Int32}
# MessageText : BYTE* optional, out -> Ptr{UInt8}
# BufferLength : SHORT -> Int16
# TextLength : SHORT* optional, out -> Ptr{Int16}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int16_t SQLError(
    void* EnvironmentHandle,
    void* ConnectionHandle,
    void* StatementHandle,
    uint8_t* Sqlstate,
    int32_t* NativeError,
    uint8_t* MessageText,
    int16_t BufferLength,
    int16_t* TextLength);
]]
local odbc32 = ffi.load("odbc32")
-- odbc32.SQLError(EnvironmentHandle, ConnectionHandle, StatementHandle, Sqlstate, NativeError, MessageText, BufferLength, TextLength)
-- EnvironmentHandle : void* in/out
-- ConnectionHandle : void* in/out
-- StatementHandle : void* in/out
-- Sqlstate : BYTE* out
-- NativeError : INT* optional, out
-- MessageText : BYTE* optional, out
-- BufferLength : SHORT
-- TextLength : SHORT* optional, out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('ODBC32.dll');
const SQLError = lib.func('__stdcall', 'SQLError', 'int16_t', ['void *', 'void *', 'void *', 'uint8_t *', 'int32_t *', 'uint8_t *', 'int16_t', 'int16_t *']);
// SQLError(EnvironmentHandle, ConnectionHandle, StatementHandle, Sqlstate, NativeError, MessageText, BufferLength, TextLength)
// EnvironmentHandle : void* in/out -> 'void *'
// ConnectionHandle : void* in/out -> 'void *'
// StatementHandle : void* in/out -> 'void *'
// Sqlstate : BYTE* out -> 'uint8_t *'
// NativeError : INT* optional, out -> 'int32_t *'
// MessageText : BYTE* optional, out -> 'uint8_t *'
// BufferLength : SHORT -> 'int16_t'
// TextLength : SHORT* optional, out -> 'int16_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("ODBC32.dll", {
  SQLError: { parameters: ["pointer", "pointer", "pointer", "pointer", "pointer", "pointer", "i16", "pointer"], result: "i16" },
});
// lib.symbols.SQLError(EnvironmentHandle, ConnectionHandle, StatementHandle, Sqlstate, NativeError, MessageText, BufferLength, TextLength)
// EnvironmentHandle : void* in/out -> "pointer"
// ConnectionHandle : void* in/out -> "pointer"
// StatementHandle : void* in/out -> "pointer"
// Sqlstate : BYTE* out -> "pointer"
// NativeError : INT* optional, out -> "pointer"
// MessageText : BYTE* optional, out -> "pointer"
// BufferLength : SHORT -> "i16"
// TextLength : SHORT* optional, out -> "pointer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int16_t SQLError(
    void* EnvironmentHandle,
    void* ConnectionHandle,
    void* StatementHandle,
    uint8_t* Sqlstate,
    int32_t* NativeError,
    uint8_t* MessageText,
    int16_t BufferLength,
    int16_t* TextLength);
C, "ODBC32.dll");
// $ffi->SQLError(EnvironmentHandle, ConnectionHandle, StatementHandle, Sqlstate, NativeError, MessageText, BufferLength, TextLength);
// EnvironmentHandle : void* in/out
// ConnectionHandle : void* in/out
// StatementHandle : void* in/out
// Sqlstate : BYTE* out
// NativeError : INT* optional, out
// MessageText : BYTE* optional, out
// BufferLength : SHORT
// TextLength : 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 SQLError(
        Pointer EnvironmentHandle,   // void* in/out
        Pointer ConnectionHandle,   // void* in/out
        Pointer StatementHandle,   // void* in/out
        byte[] Sqlstate,   // BYTE* out
        IntByReference NativeError,   // INT* optional, out
        byte[] MessageText,   // BYTE* optional, out
        short BufferLength,   // SHORT
        ShortByReference TextLength   // SHORT* optional, out
    );
}
@[Link("odbc32")]
lib LibODBC32
  fun SQLError = SQLError(
    EnvironmentHandle : Void*,   # void* in/out
    ConnectionHandle : Void*,   # void* in/out
    StatementHandle : Void*,   # void* in/out
    Sqlstate : UInt8*,   # BYTE* out
    NativeError : Int32*,   # INT* optional, out
    MessageText : UInt8*,   # BYTE* optional, out
    BufferLength : Int16,   # SHORT
    TextLength : 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 SQLErrorNative = Int16 Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Uint8>, Pointer<Int32>, Pointer<Uint8>, Int16, Pointer<Int16>);
typedef SQLErrorDart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Uint8>, Pointer<Int32>, Pointer<Uint8>, int, Pointer<Int16>);
final SQLError = DynamicLibrary.open('ODBC32.dll')
    .lookupFunction<SQLErrorNative, SQLErrorDart>('SQLError');
// EnvironmentHandle : void* in/out -> Pointer<Void>
// ConnectionHandle : void* in/out -> Pointer<Void>
// StatementHandle : void* in/out -> Pointer<Void>
// Sqlstate : BYTE* out -> Pointer<Uint8>
// NativeError : INT* optional, out -> Pointer<Int32>
// MessageText : BYTE* optional, out -> Pointer<Uint8>
// BufferLength : SHORT -> Int16
// TextLength : SHORT* optional, out -> Pointer<Int16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function SQLError(
  EnvironmentHandle: Pointer;   // void* in/out
  ConnectionHandle: Pointer;   // void* in/out
  StatementHandle: Pointer;   // void* in/out
  Sqlstate: Pointer;   // BYTE* out
  NativeError: Pointer;   // INT* optional, out
  MessageText: Pointer;   // BYTE* optional, out
  BufferLength: Smallint;   // SHORT
  TextLength: Pointer   // SHORT* optional, out
): Smallint; stdcall;
  external 'ODBC32.dll' name 'SQLError';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "SQLError"
  c_SQLError :: Ptr () -> Ptr () -> Ptr () -> Ptr Word8 -> Ptr Int32 -> Ptr Word8 -> Int16 -> Ptr Int16 -> IO Int16
-- EnvironmentHandle : void* in/out -> Ptr ()
-- ConnectionHandle : void* in/out -> Ptr ()
-- StatementHandle : void* in/out -> Ptr ()
-- Sqlstate : BYTE* out -> Ptr Word8
-- NativeError : INT* optional, out -> Ptr Int32
-- MessageText : BYTE* optional, out -> Ptr Word8
-- BufferLength : SHORT -> Int16
-- TextLength : SHORT* optional, out -> Ptr Int16
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let sqlerror =
  foreign "SQLError"
    ((ptr void) @-> (ptr void) @-> (ptr void) @-> (ptr uint8_t) @-> (ptr int32_t) @-> (ptr uint8_t) @-> int16_t @-> (ptr int16_t) @-> returning int16_t)
(* EnvironmentHandle : void* in/out -> (ptr void) *)
(* ConnectionHandle : void* in/out -> (ptr void) *)
(* StatementHandle : void* in/out -> (ptr void) *)
(* Sqlstate : BYTE* out -> (ptr uint8_t) *)
(* NativeError : INT* optional, out -> (ptr int32_t) *)
(* MessageText : BYTE* optional, out -> (ptr uint8_t) *)
(* BufferLength : SHORT -> int16_t *)
(* TextLength : 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 ("SQLError" sqlerror :convention :stdcall) :int16
  (environment-handle :pointer)   ; void* in/out
  (connection-handle :pointer)   ; void* in/out
  (statement-handle :pointer)   ; void* in/out
  (sqlstate :pointer)   ; BYTE* out
  (native-error :pointer)   ; INT* optional, out
  (message-text :pointer)   ; BYTE* optional, out
  (buffer-length :int16)   ; SHORT
  (text-length :pointer))   ; SHORT* optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $SQLError = Win32::API::More->new('ODBC32',
    'short SQLError(LPVOID EnvironmentHandle, LPVOID ConnectionHandle, LPVOID StatementHandle, LPVOID Sqlstate, LPVOID NativeError, LPVOID MessageText, short BufferLength, LPVOID TextLength)');
# my $ret = $SQLError->Call($EnvironmentHandle, $ConnectionHandle, $StatementHandle, $Sqlstate, $NativeError, $MessageText, $BufferLength, $TextLength);
# EnvironmentHandle : void* in/out -> LPVOID
# ConnectionHandle : void* in/out -> LPVOID
# StatementHandle : void* in/out -> LPVOID
# Sqlstate : BYTE* out -> LPVOID
# NativeError : INT* optional, out -> LPVOID
# MessageText : BYTE* optional, out -> LPVOID
# BufferLength : SHORT -> short
# TextLength : SHORT* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

文字セット違い