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