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