ホーム › System.Search › SQLParamOptions
SQLParamOptions
関数複数行パラメータの一括処理を設定する(非推奨)。
シグネチャ
// ODBC32.dll
#include <windows.h>
SHORT SQLParamOptions(
void* hstmt,
DWORD crow,
DWORD* pirow
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hstmt | void* | inout | 対象のステートメントハンドル。非推奨でステートメント属性に置換された。 |
| crow | DWORD | in | 処理するパラメータ集合の行数。 |
| pirow | DWORD* | inout | 現在処理中のパラメータ行番号を受け取るポインタ。 |
戻り値の型: SHORT
各言語での呼び出し定義
// ODBC32.dll
#include <windows.h>
SHORT SQLParamOptions(
void* hstmt,
DWORD crow,
DWORD* pirow
);[DllImport("ODBC32.dll", ExactSpelling = true)]
static extern short SQLParamOptions(
IntPtr hstmt, // void* in/out
uint crow, // DWORD
ref uint pirow // DWORD* in/out
);<DllImport("ODBC32.dll", ExactSpelling:=True)>
Public Shared Function SQLParamOptions(
hstmt As IntPtr, ' void* in/out
crow As UInteger, ' DWORD
ByRef pirow As UInteger ' DWORD* in/out
) As Short
End Function' hstmt : void* in/out
' crow : DWORD
' pirow : DWORD* in/out
Declare PtrSafe Function SQLParamOptions Lib "odbc32" ( _
ByVal hstmt As LongPtr, _
ByVal crow As Long, _
ByRef pirow As Long) As Integer
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SQLParamOptions = ctypes.windll.odbc32.SQLParamOptions
SQLParamOptions.restype = ctypes.c_short
SQLParamOptions.argtypes = [
ctypes.POINTER(None), # hstmt : void* in/out
wintypes.DWORD, # crow : DWORD
ctypes.POINTER(wintypes.DWORD), # pirow : DWORD* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ODBC32.dll')
SQLParamOptions = Fiddle::Function.new(
lib['SQLParamOptions'],
[
Fiddle::TYPE_VOIDP, # hstmt : void* in/out
-Fiddle::TYPE_INT, # crow : DWORD
Fiddle::TYPE_VOIDP, # pirow : DWORD* in/out
],
Fiddle::TYPE_SHORT)#[link(name = "odbc32")]
extern "system" {
fn SQLParamOptions(
hstmt: *mut (), // void* in/out
crow: u32, // DWORD
pirow: *mut u32 // DWORD* in/out
) -> i16;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ODBC32.dll")]
public static extern short SQLParamOptions(IntPtr hstmt, uint crow, ref uint pirow);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ODBC32_SQLParamOptions' -Namespace Win32 -PassThru
# $api::SQLParamOptions(hstmt, crow, pirow)#uselib "ODBC32.dll"
#func global SQLParamOptions "SQLParamOptions" sptr, sptr, sptr
; SQLParamOptions hstmt, crow, varptr(pirow) ; 戻り値は stat
; hstmt : void* in/out -> "sptr"
; crow : DWORD -> "sptr"
; pirow : DWORD* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "ODBC32.dll" #cfunc global SQLParamOptions "SQLParamOptions" sptr, int, var ; res = SQLParamOptions(hstmt, crow, pirow) ; hstmt : void* in/out -> "sptr" ; crow : DWORD -> "int" ; pirow : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ODBC32.dll" #cfunc global SQLParamOptions "SQLParamOptions" sptr, int, sptr ; res = SQLParamOptions(hstmt, crow, varptr(pirow)) ; hstmt : void* in/out -> "sptr" ; crow : DWORD -> "int" ; pirow : DWORD* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; SHORT SQLParamOptions(void* hstmt, DWORD crow, DWORD* pirow) #uselib "ODBC32.dll" #cfunc global SQLParamOptions "SQLParamOptions" intptr, int, var ; res = SQLParamOptions(hstmt, crow, pirow) ; hstmt : void* in/out -> "intptr" ; crow : DWORD -> "int" ; pirow : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; SHORT SQLParamOptions(void* hstmt, DWORD crow, DWORD* pirow) #uselib "ODBC32.dll" #cfunc global SQLParamOptions "SQLParamOptions" intptr, int, intptr ; res = SQLParamOptions(hstmt, crow, varptr(pirow)) ; hstmt : void* in/out -> "intptr" ; crow : DWORD -> "int" ; pirow : DWORD* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
odbc32 = windows.NewLazySystemDLL("ODBC32.dll")
procSQLParamOptions = odbc32.NewProc("SQLParamOptions")
)
// hstmt (void* in/out), crow (DWORD), pirow (DWORD* in/out)
r1, _, err := procSQLParamOptions.Call(
uintptr(hstmt),
uintptr(crow),
uintptr(pirow),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // SHORTfunction SQLParamOptions(
hstmt: Pointer; // void* in/out
crow: DWORD; // DWORD
pirow: Pointer // DWORD* in/out
): Smallint; stdcall;
external 'ODBC32.dll' name 'SQLParamOptions';result := DllCall("ODBC32\SQLParamOptions"
, "Ptr", hstmt ; void* in/out
, "UInt", crow ; DWORD
, "Ptr", pirow ; DWORD* in/out
, "Short") ; return: SHORT●SQLParamOptions(hstmt, crow, pirow) = DLL("ODBC32.dll", "int SQLParamOptions(void*, dword, void*)")
# 呼び出し: SQLParamOptions(hstmt, crow, pirow)
# hstmt : void* in/out -> "void*"
# crow : DWORD -> "dword"
# pirow : DWORD* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "odbc32" fn SQLParamOptions(
hstmt: ?*anyopaque, // void* in/out
crow: u32, // DWORD
pirow: [*c]u32 // DWORD* in/out
) callconv(std.os.windows.WINAPI) i16;proc SQLParamOptions(
hstmt: pointer, # void* in/out
crow: uint32, # DWORD
pirow: ptr uint32 # DWORD* in/out
): int16 {.importc: "SQLParamOptions", stdcall, dynlib: "ODBC32.dll".}pragma(lib, "odbc32");
extern(Windows)
short SQLParamOptions(
void* hstmt, // void* in/out
uint crow, // DWORD
uint* pirow // DWORD* in/out
);ccall((:SQLParamOptions, "ODBC32.dll"), stdcall, Int16,
(Ptr{Cvoid}, UInt32, Ptr{UInt32}),
hstmt, crow, pirow)
# hstmt : void* in/out -> Ptr{Cvoid}
# crow : DWORD -> UInt32
# pirow : DWORD* in/out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int16_t SQLParamOptions(
void* hstmt,
uint32_t crow,
uint32_t* pirow);
]]
local odbc32 = ffi.load("odbc32")
-- odbc32.SQLParamOptions(hstmt, crow, pirow)
-- hstmt : void* in/out
-- crow : DWORD
-- pirow : DWORD* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('ODBC32.dll');
const SQLParamOptions = lib.func('__stdcall', 'SQLParamOptions', 'int16_t', ['void *', 'uint32_t', 'uint32_t *']);
// SQLParamOptions(hstmt, crow, pirow)
// hstmt : void* in/out -> 'void *'
// crow : DWORD -> 'uint32_t'
// pirow : DWORD* in/out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("ODBC32.dll", {
SQLParamOptions: { parameters: ["pointer", "u32", "pointer"], result: "i16" },
});
// lib.symbols.SQLParamOptions(hstmt, crow, pirow)
// hstmt : void* in/out -> "pointer"
// crow : DWORD -> "u32"
// pirow : DWORD* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int16_t SQLParamOptions(
void* hstmt,
uint32_t crow,
uint32_t* pirow);
C, "ODBC32.dll");
// $ffi->SQLParamOptions(hstmt, crow, pirow);
// hstmt : void* in/out
// crow : DWORD
// pirow : DWORD* in/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);
short SQLParamOptions(
Pointer hstmt, // void* in/out
int crow, // DWORD
IntByReference pirow // DWORD* in/out
);
}@[Link("odbc32")]
lib LibODBC32
fun SQLParamOptions = SQLParamOptions(
hstmt : Void*, # void* in/out
crow : UInt32, # DWORD
pirow : UInt32* # DWORD* in/out
) : Int16
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef SQLParamOptionsNative = Int16 Function(Pointer<Void>, Uint32, Pointer<Uint32>);
typedef SQLParamOptionsDart = int Function(Pointer<Void>, int, Pointer<Uint32>);
final SQLParamOptions = DynamicLibrary.open('ODBC32.dll')
.lookupFunction<SQLParamOptionsNative, SQLParamOptionsDart>('SQLParamOptions');
// hstmt : void* in/out -> Pointer<Void>
// crow : DWORD -> Uint32
// pirow : DWORD* in/out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SQLParamOptions(
hstmt: Pointer; // void* in/out
crow: DWORD; // DWORD
pirow: Pointer // DWORD* in/out
): Smallint; stdcall;
external 'ODBC32.dll' name 'SQLParamOptions';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SQLParamOptions"
c_SQLParamOptions :: Ptr () -> Word32 -> Ptr Word32 -> IO Int16
-- hstmt : void* in/out -> Ptr ()
-- crow : DWORD -> Word32
-- pirow : DWORD* in/out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let sqlparamoptions =
foreign "SQLParamOptions"
((ptr void) @-> uint32_t @-> (ptr uint32_t) @-> returning int16_t)
(* hstmt : void* in/out -> (ptr void) *)
(* crow : DWORD -> uint32_t *)
(* pirow : DWORD* in/out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library odbc32 (t "ODBC32.dll"))
(cffi:use-foreign-library odbc32)
(cffi:defcfun ("SQLParamOptions" sqlparam-options :convention :stdcall) :int16
(hstmt :pointer) ; void* in/out
(crow :uint32) ; DWORD
(pirow :pointer)) ; DWORD* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SQLParamOptions = Win32::API::More->new('ODBC32',
'short SQLParamOptions(LPVOID hstmt, DWORD crow, LPVOID pirow)');
# my $ret = $SQLParamOptions->Call($hstmt, $crow, $pirow);
# hstmt : void* in/out -> LPVOID
# crow : DWORD -> DWORD
# pirow : DWORD* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。