ホーム › System.Search › SQLSetDescRec
SQLSetDescRec
関数記述子レコードの複数フィールドをまとめて設定する。
シグネチャ
// ODBC32.dll
#include <windows.h>
SHORT SQLSetDescRec(
void* DescriptorHandle,
SHORT RecNumber,
SHORT Type,
SHORT SubType,
INT Length,
SHORT Precision,
SHORT Scale,
void* Data, // optional
INT* StringLength, // optional
INT* Indicator // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| DescriptorHandle | void* | inout | レコードを設定する対象の記述子ハンドル。 |
| RecNumber | SHORT | in | 設定対象のレコード番号。1始まりで指定する。 |
| Type | SHORT | in | 設定するデータ型(SQL型)を指定する。 |
| SubType | SHORT | in | 日時/区間型の場合のサブタイプを指定する。 |
| Length | INT | in | データの長さ(オクテット長)を指定する。 |
| Precision | SHORT | in | 数値の有効桁数(精度)を指定する。 |
| Scale | SHORT | in | 小数点以下桁数(スケール)を指定する。 |
| Data | void* | inoutoptional | データバッファへのポインタ。SQL_DESC_DATA_PTRに設定される。 |
| StringLength | INT* | inoutoptional | データの長さを保持するポインタ(SQL_DESC_OCTET_LENGTH_PTR)。 |
| Indicator | INT* | inoutoptional | 標識値を保持するポインタ(SQL_DESC_INDICATOR_PTR)。 |
戻り値の型: SHORT
各言語での呼び出し定義
// ODBC32.dll
#include <windows.h>
SHORT SQLSetDescRec(
void* DescriptorHandle,
SHORT RecNumber,
SHORT Type,
SHORT SubType,
INT Length,
SHORT Precision,
SHORT Scale,
void* Data, // optional
INT* StringLength, // optional
INT* Indicator // optional
);[DllImport("ODBC32.dll", ExactSpelling = true)]
static extern short SQLSetDescRec(
IntPtr DescriptorHandle, // void* in/out
short RecNumber, // SHORT
short Type, // SHORT
short SubType, // SHORT
int Length, // INT
short Precision, // SHORT
short Scale, // SHORT
IntPtr Data, // void* optional, in/out
IntPtr StringLength, // INT* optional, in/out
IntPtr Indicator // INT* optional, in/out
);<DllImport("ODBC32.dll", ExactSpelling:=True)>
Public Shared Function SQLSetDescRec(
DescriptorHandle As IntPtr, ' void* in/out
RecNumber As Short, ' SHORT
Type As Short, ' SHORT
SubType As Short, ' SHORT
Length As Integer, ' INT
Precision As Short, ' SHORT
Scale As Short, ' SHORT
Data As IntPtr, ' void* optional, in/out
StringLength As IntPtr, ' INT* optional, in/out
Indicator As IntPtr ' INT* optional, in/out
) As Short
End Function' DescriptorHandle : void* in/out
' RecNumber : SHORT
' Type : SHORT
' SubType : SHORT
' Length : INT
' Precision : SHORT
' Scale : SHORT
' Data : void* optional, in/out
' StringLength : INT* optional, in/out
' Indicator : INT* optional, in/out
Declare PtrSafe Function SQLSetDescRec Lib "odbc32" ( _
ByVal DescriptorHandle As LongPtr, _
ByVal RecNumber As Integer, _
ByVal Type As Integer, _
ByVal SubType As Integer, _
ByVal Length As Long, _
ByVal Precision As Integer, _
ByVal Scale As Integer, _
ByVal Data As LongPtr, _
ByVal StringLength As LongPtr, _
ByVal Indicator As LongPtr) As Integer
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SQLSetDescRec = ctypes.windll.odbc32.SQLSetDescRec
SQLSetDescRec.restype = ctypes.c_short
SQLSetDescRec.argtypes = [
ctypes.POINTER(None), # DescriptorHandle : void* in/out
ctypes.c_short, # RecNumber : SHORT
ctypes.c_short, # Type : SHORT
ctypes.c_short, # SubType : SHORT
ctypes.c_int, # Length : INT
ctypes.c_short, # Precision : SHORT
ctypes.c_short, # Scale : SHORT
ctypes.POINTER(None), # Data : void* optional, in/out
ctypes.POINTER(ctypes.c_int), # StringLength : INT* optional, in/out
ctypes.POINTER(ctypes.c_int), # Indicator : INT* optional, in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ODBC32.dll')
SQLSetDescRec = Fiddle::Function.new(
lib['SQLSetDescRec'],
[
Fiddle::TYPE_VOIDP, # DescriptorHandle : void* in/out
Fiddle::TYPE_SHORT, # RecNumber : SHORT
Fiddle::TYPE_SHORT, # Type : SHORT
Fiddle::TYPE_SHORT, # SubType : SHORT
Fiddle::TYPE_INT, # Length : INT
Fiddle::TYPE_SHORT, # Precision : SHORT
Fiddle::TYPE_SHORT, # Scale : SHORT
Fiddle::TYPE_VOIDP, # Data : void* optional, in/out
Fiddle::TYPE_VOIDP, # StringLength : INT* optional, in/out
Fiddle::TYPE_VOIDP, # Indicator : INT* optional, in/out
],
Fiddle::TYPE_SHORT)#[link(name = "odbc32")]
extern "system" {
fn SQLSetDescRec(
DescriptorHandle: *mut (), // void* in/out
RecNumber: i16, // SHORT
Type: i16, // SHORT
SubType: i16, // SHORT
Length: i32, // INT
Precision: i16, // SHORT
Scale: i16, // SHORT
Data: *mut (), // void* optional, in/out
StringLength: *mut i32, // INT* optional, in/out
Indicator: *mut i32 // INT* optional, in/out
) -> i16;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ODBC32.dll")]
public static extern short SQLSetDescRec(IntPtr DescriptorHandle, short RecNumber, short Type, short SubType, int Length, short Precision, short Scale, IntPtr Data, IntPtr StringLength, IntPtr Indicator);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ODBC32_SQLSetDescRec' -Namespace Win32 -PassThru
# $api::SQLSetDescRec(DescriptorHandle, RecNumber, Type, SubType, Length, Precision, Scale, Data, StringLength, Indicator)#uselib "ODBC32.dll"
#func global SQLSetDescRec "SQLSetDescRec" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; SQLSetDescRec DescriptorHandle, RecNumber, Type, SubType, Length, Precision, Scale, Data, varptr(StringLength), varptr(Indicator) ; 戻り値は stat
; DescriptorHandle : void* in/out -> "sptr"
; RecNumber : SHORT -> "sptr"
; Type : SHORT -> "sptr"
; SubType : SHORT -> "sptr"
; Length : INT -> "sptr"
; Precision : SHORT -> "sptr"
; Scale : SHORT -> "sptr"
; Data : void* optional, in/out -> "sptr"
; StringLength : INT* optional, in/out -> "sptr"
; Indicator : INT* optional, in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "ODBC32.dll" #cfunc global SQLSetDescRec "SQLSetDescRec" sptr, int, int, int, int, int, int, sptr, var, var ; res = SQLSetDescRec(DescriptorHandle, RecNumber, Type, SubType, Length, Precision, Scale, Data, StringLength, Indicator) ; DescriptorHandle : void* in/out -> "sptr" ; RecNumber : SHORT -> "int" ; Type : SHORT -> "int" ; SubType : SHORT -> "int" ; Length : INT -> "int" ; Precision : SHORT -> "int" ; Scale : SHORT -> "int" ; Data : void* optional, in/out -> "sptr" ; StringLength : INT* optional, in/out -> "var" ; Indicator : INT* optional, in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ODBC32.dll" #cfunc global SQLSetDescRec "SQLSetDescRec" sptr, int, int, int, int, int, int, sptr, sptr, sptr ; res = SQLSetDescRec(DescriptorHandle, RecNumber, Type, SubType, Length, Precision, Scale, Data, varptr(StringLength), varptr(Indicator)) ; DescriptorHandle : void* in/out -> "sptr" ; RecNumber : SHORT -> "int" ; Type : SHORT -> "int" ; SubType : SHORT -> "int" ; Length : INT -> "int" ; Precision : SHORT -> "int" ; Scale : SHORT -> "int" ; Data : void* optional, in/out -> "sptr" ; StringLength : INT* optional, in/out -> "sptr" ; Indicator : INT* optional, in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; SHORT SQLSetDescRec(void* DescriptorHandle, SHORT RecNumber, SHORT Type, SHORT SubType, INT Length, SHORT Precision, SHORT Scale, void* Data, INT* StringLength, INT* Indicator) #uselib "ODBC32.dll" #cfunc global SQLSetDescRec "SQLSetDescRec" intptr, int, int, int, int, int, int, intptr, var, var ; res = SQLSetDescRec(DescriptorHandle, RecNumber, Type, SubType, Length, Precision, Scale, Data, StringLength, Indicator) ; DescriptorHandle : void* in/out -> "intptr" ; RecNumber : SHORT -> "int" ; Type : SHORT -> "int" ; SubType : SHORT -> "int" ; Length : INT -> "int" ; Precision : SHORT -> "int" ; Scale : SHORT -> "int" ; Data : void* optional, in/out -> "intptr" ; StringLength : INT* optional, in/out -> "var" ; Indicator : INT* optional, in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; SHORT SQLSetDescRec(void* DescriptorHandle, SHORT RecNumber, SHORT Type, SHORT SubType, INT Length, SHORT Precision, SHORT Scale, void* Data, INT* StringLength, INT* Indicator) #uselib "ODBC32.dll" #cfunc global SQLSetDescRec "SQLSetDescRec" intptr, int, int, int, int, int, int, intptr, intptr, intptr ; res = SQLSetDescRec(DescriptorHandle, RecNumber, Type, SubType, Length, Precision, Scale, Data, varptr(StringLength), varptr(Indicator)) ; DescriptorHandle : void* in/out -> "intptr" ; RecNumber : SHORT -> "int" ; Type : SHORT -> "int" ; SubType : SHORT -> "int" ; Length : INT -> "int" ; Precision : SHORT -> "int" ; Scale : SHORT -> "int" ; Data : void* optional, in/out -> "intptr" ; StringLength : INT* optional, in/out -> "intptr" ; Indicator : INT* optional, in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
odbc32 = windows.NewLazySystemDLL("ODBC32.dll")
procSQLSetDescRec = odbc32.NewProc("SQLSetDescRec")
)
// DescriptorHandle (void* in/out), RecNumber (SHORT), Type (SHORT), SubType (SHORT), Length (INT), Precision (SHORT), Scale (SHORT), Data (void* optional, in/out), StringLength (INT* optional, in/out), Indicator (INT* optional, in/out)
r1, _, err := procSQLSetDescRec.Call(
uintptr(DescriptorHandle),
uintptr(RecNumber),
uintptr(Type),
uintptr(SubType),
uintptr(Length),
uintptr(Precision),
uintptr(Scale),
uintptr(Data),
uintptr(StringLength),
uintptr(Indicator),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // SHORTfunction SQLSetDescRec(
DescriptorHandle: Pointer; // void* in/out
RecNumber: Smallint; // SHORT
Type: Smallint; // SHORT
SubType: Smallint; // SHORT
Length: Integer; // INT
Precision: Smallint; // SHORT
Scale: Smallint; // SHORT
Data: Pointer; // void* optional, in/out
StringLength: Pointer; // INT* optional, in/out
Indicator: Pointer // INT* optional, in/out
): Smallint; stdcall;
external 'ODBC32.dll' name 'SQLSetDescRec';result := DllCall("ODBC32\SQLSetDescRec"
, "Ptr", DescriptorHandle ; void* in/out
, "Short", RecNumber ; SHORT
, "Short", Type ; SHORT
, "Short", SubType ; SHORT
, "Int", Length ; INT
, "Short", Precision ; SHORT
, "Short", Scale ; SHORT
, "Ptr", Data ; void* optional, in/out
, "Ptr", StringLength ; INT* optional, in/out
, "Ptr", Indicator ; INT* optional, in/out
, "Short") ; return: SHORT●SQLSetDescRec(DescriptorHandle, RecNumber, Type, SubType, Length, Precision, Scale, Data, StringLength, Indicator) = DLL("ODBC32.dll", "int SQLSetDescRec(void*, int, int, int, int, int, int, void*, void*, void*)")
# 呼び出し: SQLSetDescRec(DescriptorHandle, RecNumber, Type, SubType, Length, Precision, Scale, Data, StringLength, Indicator)
# DescriptorHandle : void* in/out -> "void*"
# RecNumber : SHORT -> "int"
# Type : SHORT -> "int"
# SubType : SHORT -> "int"
# Length : INT -> "int"
# Precision : SHORT -> "int"
# Scale : SHORT -> "int"
# Data : void* optional, in/out -> "void*"
# StringLength : INT* optional, in/out -> "void*"
# Indicator : INT* optional, in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "odbc32" fn SQLSetDescRec(
DescriptorHandle: ?*anyopaque, // void* in/out
RecNumber: i16, // SHORT
Type: i16, // SHORT
SubType: i16, // SHORT
Length: i32, // INT
Precision: i16, // SHORT
Scale: i16, // SHORT
Data: ?*anyopaque, // void* optional, in/out
StringLength: [*c]i32, // INT* optional, in/out
Indicator: [*c]i32 // INT* optional, in/out
) callconv(std.os.windows.WINAPI) i16;proc SQLSetDescRec(
DescriptorHandle: pointer, # void* in/out
RecNumber: int16, # SHORT
Type: int16, # SHORT
SubType: int16, # SHORT
Length: int32, # INT
Precision: int16, # SHORT
Scale: int16, # SHORT
Data: pointer, # void* optional, in/out
StringLength: ptr int32, # INT* optional, in/out
Indicator: ptr int32 # INT* optional, in/out
): int16 {.importc: "SQLSetDescRec", stdcall, dynlib: "ODBC32.dll".}pragma(lib, "odbc32");
extern(Windows)
short SQLSetDescRec(
void* DescriptorHandle, // void* in/out
short RecNumber, // SHORT
short Type, // SHORT
short SubType, // SHORT
int Length, // INT
short Precision, // SHORT
short Scale, // SHORT
void* Data, // void* optional, in/out
int* StringLength, // INT* optional, in/out
int* Indicator // INT* optional, in/out
);ccall((:SQLSetDescRec, "ODBC32.dll"), stdcall, Int16,
(Ptr{Cvoid}, Int16, Int16, Int16, Int32, Int16, Int16, Ptr{Cvoid}, Ptr{Int32}, Ptr{Int32}),
DescriptorHandle, RecNumber, Type, SubType, Length, Precision, Scale, Data, StringLength, Indicator)
# DescriptorHandle : void* in/out -> Ptr{Cvoid}
# RecNumber : SHORT -> Int16
# Type : SHORT -> Int16
# SubType : SHORT -> Int16
# Length : INT -> Int32
# Precision : SHORT -> Int16
# Scale : SHORT -> Int16
# Data : void* optional, in/out -> Ptr{Cvoid}
# StringLength : INT* optional, in/out -> Ptr{Int32}
# Indicator : INT* optional, in/out -> Ptr{Int32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int16_t SQLSetDescRec(
void* DescriptorHandle,
int16_t RecNumber,
int16_t Type,
int16_t SubType,
int32_t Length,
int16_t Precision,
int16_t Scale,
void* Data,
int32_t* StringLength,
int32_t* Indicator);
]]
local odbc32 = ffi.load("odbc32")
-- odbc32.SQLSetDescRec(DescriptorHandle, RecNumber, Type, SubType, Length, Precision, Scale, Data, StringLength, Indicator)
-- DescriptorHandle : void* in/out
-- RecNumber : SHORT
-- Type : SHORT
-- SubType : SHORT
-- Length : INT
-- Precision : SHORT
-- Scale : SHORT
-- Data : void* optional, in/out
-- StringLength : INT* optional, in/out
-- Indicator : INT* optional, in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('ODBC32.dll');
const SQLSetDescRec = lib.func('__stdcall', 'SQLSetDescRec', 'int16_t', ['void *', 'int16_t', 'int16_t', 'int16_t', 'int32_t', 'int16_t', 'int16_t', 'void *', 'int32_t *', 'int32_t *']);
// SQLSetDescRec(DescriptorHandle, RecNumber, Type, SubType, Length, Precision, Scale, Data, StringLength, Indicator)
// DescriptorHandle : void* in/out -> 'void *'
// RecNumber : SHORT -> 'int16_t'
// Type : SHORT -> 'int16_t'
// SubType : SHORT -> 'int16_t'
// Length : INT -> 'int32_t'
// Precision : SHORT -> 'int16_t'
// Scale : SHORT -> 'int16_t'
// Data : void* optional, in/out -> 'void *'
// StringLength : INT* optional, in/out -> 'int32_t *'
// Indicator : INT* optional, in/out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("ODBC32.dll", {
SQLSetDescRec: { parameters: ["pointer", "i16", "i16", "i16", "i32", "i16", "i16", "pointer", "pointer", "pointer"], result: "i16" },
});
// lib.symbols.SQLSetDescRec(DescriptorHandle, RecNumber, Type, SubType, Length, Precision, Scale, Data, StringLength, Indicator)
// DescriptorHandle : void* in/out -> "pointer"
// RecNumber : SHORT -> "i16"
// Type : SHORT -> "i16"
// SubType : SHORT -> "i16"
// Length : INT -> "i32"
// Precision : SHORT -> "i16"
// Scale : SHORT -> "i16"
// Data : void* optional, in/out -> "pointer"
// StringLength : INT* optional, in/out -> "pointer"
// Indicator : INT* optional, in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int16_t SQLSetDescRec(
void* DescriptorHandle,
int16_t RecNumber,
int16_t Type,
int16_t SubType,
int32_t Length,
int16_t Precision,
int16_t Scale,
void* Data,
int32_t* StringLength,
int32_t* Indicator);
C, "ODBC32.dll");
// $ffi->SQLSetDescRec(DescriptorHandle, RecNumber, Type, SubType, Length, Precision, Scale, Data, StringLength, Indicator);
// DescriptorHandle : void* in/out
// RecNumber : SHORT
// Type : SHORT
// SubType : SHORT
// Length : INT
// Precision : SHORT
// Scale : SHORT
// Data : void* optional, in/out
// StringLength : INT* optional, in/out
// Indicator : INT* optional, 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 SQLSetDescRec(
Pointer DescriptorHandle, // void* in/out
short RecNumber, // SHORT
short Type, // SHORT
short SubType, // SHORT
int Length, // INT
short Precision, // SHORT
short Scale, // SHORT
Pointer Data, // void* optional, in/out
IntByReference StringLength, // INT* optional, in/out
IntByReference Indicator // INT* optional, in/out
);
}@[Link("odbc32")]
lib LibODBC32
fun SQLSetDescRec = SQLSetDescRec(
DescriptorHandle : Void*, # void* in/out
RecNumber : Int16, # SHORT
Type : Int16, # SHORT
SubType : Int16, # SHORT
Length : Int32, # INT
Precision : Int16, # SHORT
Scale : Int16, # SHORT
Data : Void*, # void* optional, in/out
StringLength : Int32*, # INT* optional, in/out
Indicator : Int32* # INT* optional, 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 SQLSetDescRecNative = Int16 Function(Pointer<Void>, Int16, Int16, Int16, Int32, Int16, Int16, Pointer<Void>, Pointer<Int32>, Pointer<Int32>);
typedef SQLSetDescRecDart = int Function(Pointer<Void>, int, int, int, int, int, int, Pointer<Void>, Pointer<Int32>, Pointer<Int32>);
final SQLSetDescRec = DynamicLibrary.open('ODBC32.dll')
.lookupFunction<SQLSetDescRecNative, SQLSetDescRecDart>('SQLSetDescRec');
// DescriptorHandle : void* in/out -> Pointer<Void>
// RecNumber : SHORT -> Int16
// Type : SHORT -> Int16
// SubType : SHORT -> Int16
// Length : INT -> Int32
// Precision : SHORT -> Int16
// Scale : SHORT -> Int16
// Data : void* optional, in/out -> Pointer<Void>
// StringLength : INT* optional, in/out -> Pointer<Int32>
// Indicator : INT* optional, in/out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SQLSetDescRec(
DescriptorHandle: Pointer; // void* in/out
RecNumber: Smallint; // SHORT
Type: Smallint; // SHORT
SubType: Smallint; // SHORT
Length: Integer; // INT
Precision: Smallint; // SHORT
Scale: Smallint; // SHORT
Data: Pointer; // void* optional, in/out
StringLength: Pointer; // INT* optional, in/out
Indicator: Pointer // INT* optional, in/out
): Smallint; stdcall;
external 'ODBC32.dll' name 'SQLSetDescRec';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SQLSetDescRec"
c_SQLSetDescRec :: Ptr () -> Int16 -> Int16 -> Int16 -> Int32 -> Int16 -> Int16 -> Ptr () -> Ptr Int32 -> Ptr Int32 -> IO Int16
-- DescriptorHandle : void* in/out -> Ptr ()
-- RecNumber : SHORT -> Int16
-- Type : SHORT -> Int16
-- SubType : SHORT -> Int16
-- Length : INT -> Int32
-- Precision : SHORT -> Int16
-- Scale : SHORT -> Int16
-- Data : void* optional, in/out -> Ptr ()
-- StringLength : INT* optional, in/out -> Ptr Int32
-- Indicator : INT* optional, in/out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let sqlsetdescrec =
foreign "SQLSetDescRec"
((ptr void) @-> int16_t @-> int16_t @-> int16_t @-> int32_t @-> int16_t @-> int16_t @-> (ptr void) @-> (ptr int32_t) @-> (ptr int32_t) @-> returning int16_t)
(* DescriptorHandle : void* in/out -> (ptr void) *)
(* RecNumber : SHORT -> int16_t *)
(* Type : SHORT -> int16_t *)
(* SubType : SHORT -> int16_t *)
(* Length : INT -> int32_t *)
(* Precision : SHORT -> int16_t *)
(* Scale : SHORT -> int16_t *)
(* Data : void* optional, in/out -> (ptr void) *)
(* StringLength : INT* optional, in/out -> (ptr int32_t) *)
(* Indicator : INT* optional, in/out -> (ptr int32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library odbc32 (t "ODBC32.dll"))
(cffi:use-foreign-library odbc32)
(cffi:defcfun ("SQLSetDescRec" sqlset-desc-rec :convention :stdcall) :int16
(descriptor-handle :pointer) ; void* in/out
(rec-number :int16) ; SHORT
(type :int16) ; SHORT
(sub-type :int16) ; SHORT
(length :int32) ; INT
(precision :int16) ; SHORT
(scale :int16) ; SHORT
(data :pointer) ; void* optional, in/out
(string-length :pointer) ; INT* optional, in/out
(indicator :pointer)) ; INT* optional, in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SQLSetDescRec = Win32::API::More->new('ODBC32',
'short SQLSetDescRec(LPVOID DescriptorHandle, short RecNumber, short Type, short SubType, int Length, short Precision, short Scale, LPVOID Data, LPVOID StringLength, LPVOID Indicator)');
# my $ret = $SQLSetDescRec->Call($DescriptorHandle, $RecNumber, $Type, $SubType, $Length, $Precision, $Scale, $Data, $StringLength, $Indicator);
# DescriptorHandle : void* in/out -> LPVOID
# RecNumber : SHORT -> short
# Type : SHORT -> short
# SubType : SHORT -> short
# Length : INT -> int
# Precision : SHORT -> short
# Scale : SHORT -> short
# Data : void* optional, in/out -> LPVOID
# StringLength : INT* optional, in/out -> LPVOID
# Indicator : INT* optional, in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。