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