ホーム › System.Search › SQLSetDescField
SQLSetDescField
関数記述子レコードの指定フィールドに値を設定する。
シグネチャ
// ODBC32.dll (ANSI / -A)
#include <windows.h>
SHORT SQLSetDescField(
void* DescriptorHandle,
SHORT RecNumber,
SHORT FieldIdentifier,
void* Value,
INT BufferLength
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| DescriptorHandle | void* | inout | フィールドを設定する対象の記述子ハンドル。 |
| RecNumber | SHORT | in | 設定対象のレコード番号。1始まりで指定する。 |
| FieldIdentifier | SHORT | in | 設定するフィールドのID。SQL_DESC_*定数を指定する。 |
| Value | void* | in | 設定する値。整数または文字列バッファへのポインタ。 |
| BufferLength | INT | in | Valueが文字列の場合のバイト長。整数ならSQL_IS_INTEGER等。 |
戻り値の型: SHORT
各言語での呼び出し定義
// ODBC32.dll (ANSI / -A)
#include <windows.h>
SHORT SQLSetDescField(
void* DescriptorHandle,
SHORT RecNumber,
SHORT FieldIdentifier,
void* Value,
INT BufferLength
);[DllImport("ODBC32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern short SQLSetDescField(
IntPtr DescriptorHandle, // void* in/out
short RecNumber, // SHORT
short FieldIdentifier, // SHORT
IntPtr Value, // void*
int BufferLength // INT
);<DllImport("ODBC32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function SQLSetDescField(
DescriptorHandle As IntPtr, ' void* in/out
RecNumber As Short, ' SHORT
FieldIdentifier As Short, ' SHORT
Value As IntPtr, ' void*
BufferLength As Integer ' INT
) As Short
End Function' DescriptorHandle : void* in/out
' RecNumber : SHORT
' FieldIdentifier : SHORT
' Value : void*
' BufferLength : INT
Declare PtrSafe Function SQLSetDescField Lib "odbc32" ( _
ByVal DescriptorHandle As LongPtr, _
ByVal RecNumber As Integer, _
ByVal FieldIdentifier As Integer, _
ByVal Value As LongPtr, _
ByVal BufferLength As Long) As Integer
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SQLSetDescField = ctypes.windll.odbc32.SQLSetDescField
SQLSetDescField.restype = ctypes.c_short
SQLSetDescField.argtypes = [
ctypes.POINTER(None), # DescriptorHandle : void* in/out
ctypes.c_short, # RecNumber : SHORT
ctypes.c_short, # FieldIdentifier : SHORT
ctypes.POINTER(None), # Value : void*
ctypes.c_int, # BufferLength : INT
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ODBC32.dll')
SQLSetDescField = Fiddle::Function.new(
lib['SQLSetDescField'],
[
Fiddle::TYPE_VOIDP, # DescriptorHandle : void* in/out
Fiddle::TYPE_SHORT, # RecNumber : SHORT
Fiddle::TYPE_SHORT, # FieldIdentifier : SHORT
Fiddle::TYPE_VOIDP, # Value : void*
Fiddle::TYPE_INT, # BufferLength : INT
],
Fiddle::TYPE_SHORT)#[link(name = "odbc32")]
extern "system" {
fn SQLSetDescField(
DescriptorHandle: *mut (), // void* in/out
RecNumber: i16, // SHORT
FieldIdentifier: i16, // SHORT
Value: *mut (), // void*
BufferLength: i32 // INT
) -> i16;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ODBC32.dll", CharSet = CharSet.Ansi)]
public static extern short SQLSetDescField(IntPtr DescriptorHandle, short RecNumber, short FieldIdentifier, IntPtr Value, int BufferLength);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ODBC32_SQLSetDescField' -Namespace Win32 -PassThru
# $api::SQLSetDescField(DescriptorHandle, RecNumber, FieldIdentifier, Value, BufferLength)#uselib "ODBC32.dll"
#func global SQLSetDescField "SQLSetDescField" sptr, sptr, sptr, sptr, sptr
; SQLSetDescField DescriptorHandle, RecNumber, FieldIdentifier, Value, BufferLength ; 戻り値は stat
; DescriptorHandle : void* in/out -> "sptr"
; RecNumber : SHORT -> "sptr"
; FieldIdentifier : SHORT -> "sptr"
; Value : void* -> "sptr"
; BufferLength : INT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "ODBC32.dll"
#cfunc global SQLSetDescField "SQLSetDescField" sptr, int, int, sptr, int
; res = SQLSetDescField(DescriptorHandle, RecNumber, FieldIdentifier, Value, BufferLength)
; DescriptorHandle : void* in/out -> "sptr"
; RecNumber : SHORT -> "int"
; FieldIdentifier : SHORT -> "int"
; Value : void* -> "sptr"
; BufferLength : INT -> "int"; SHORT SQLSetDescField(void* DescriptorHandle, SHORT RecNumber, SHORT FieldIdentifier, void* Value, INT BufferLength)
#uselib "ODBC32.dll"
#cfunc global SQLSetDescField "SQLSetDescField" intptr, int, int, intptr, int
; res = SQLSetDescField(DescriptorHandle, RecNumber, FieldIdentifier, Value, BufferLength)
; DescriptorHandle : void* in/out -> "intptr"
; RecNumber : SHORT -> "int"
; FieldIdentifier : SHORT -> "int"
; Value : void* -> "intptr"
; BufferLength : INT -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
odbc32 = windows.NewLazySystemDLL("ODBC32.dll")
procSQLSetDescField = odbc32.NewProc("SQLSetDescField")
)
// DescriptorHandle (void* in/out), RecNumber (SHORT), FieldIdentifier (SHORT), Value (void*), BufferLength (INT)
r1, _, err := procSQLSetDescField.Call(
uintptr(DescriptorHandle),
uintptr(RecNumber),
uintptr(FieldIdentifier),
uintptr(Value),
uintptr(BufferLength),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // SHORTfunction SQLSetDescField(
DescriptorHandle: Pointer; // void* in/out
RecNumber: Smallint; // SHORT
FieldIdentifier: Smallint; // SHORT
Value: Pointer; // void*
BufferLength: Integer // INT
): Smallint; stdcall;
external 'ODBC32.dll' name 'SQLSetDescField';result := DllCall("ODBC32\SQLSetDescField"
, "Ptr", DescriptorHandle ; void* in/out
, "Short", RecNumber ; SHORT
, "Short", FieldIdentifier ; SHORT
, "Ptr", Value ; void*
, "Int", BufferLength ; INT
, "Short") ; return: SHORT●SQLSetDescField(DescriptorHandle, RecNumber, FieldIdentifier, Value, BufferLength) = DLL("ODBC32.dll", "int SQLSetDescField(void*, int, int, void*, int)")
# 呼び出し: SQLSetDescField(DescriptorHandle, RecNumber, FieldIdentifier, Value, BufferLength)
# DescriptorHandle : void* in/out -> "void*"
# RecNumber : SHORT -> "int"
# FieldIdentifier : SHORT -> "int"
# Value : void* -> "void*"
# BufferLength : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "odbc32" fn SQLSetDescField(
DescriptorHandle: ?*anyopaque, // void* in/out
RecNumber: i16, // SHORT
FieldIdentifier: i16, // SHORT
Value: ?*anyopaque, // void*
BufferLength: i32 // INT
) callconv(std.os.windows.WINAPI) i16;proc SQLSetDescField(
DescriptorHandle: pointer, # void* in/out
RecNumber: int16, # SHORT
FieldIdentifier: int16, # SHORT
Value: pointer, # void*
BufferLength: int32 # INT
): int16 {.importc: "SQLSetDescField", stdcall, dynlib: "ODBC32.dll".}pragma(lib, "odbc32");
extern(Windows)
short SQLSetDescField(
void* DescriptorHandle, // void* in/out
short RecNumber, // SHORT
short FieldIdentifier, // SHORT
void* Value, // void*
int BufferLength // INT
);ccall((:SQLSetDescField, "ODBC32.dll"), stdcall, Int16,
(Ptr{Cvoid}, Int16, Int16, Ptr{Cvoid}, Int32),
DescriptorHandle, RecNumber, FieldIdentifier, Value, BufferLength)
# DescriptorHandle : void* in/out -> Ptr{Cvoid}
# RecNumber : SHORT -> Int16
# FieldIdentifier : SHORT -> Int16
# Value : void* -> Ptr{Cvoid}
# BufferLength : INT -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int16_t SQLSetDescField(
void* DescriptorHandle,
int16_t RecNumber,
int16_t FieldIdentifier,
void* Value,
int32_t BufferLength);
]]
local odbc32 = ffi.load("odbc32")
-- odbc32.SQLSetDescField(DescriptorHandle, RecNumber, FieldIdentifier, Value, BufferLength)
-- DescriptorHandle : void* in/out
-- RecNumber : SHORT
-- FieldIdentifier : SHORT
-- Value : void*
-- BufferLength : INT
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('ODBC32.dll');
const SQLSetDescField = lib.func('__stdcall', 'SQLSetDescField', 'int16_t', ['void *', 'int16_t', 'int16_t', 'void *', 'int32_t']);
// SQLSetDescField(DescriptorHandle, RecNumber, FieldIdentifier, Value, BufferLength)
// DescriptorHandle : void* in/out -> 'void *'
// RecNumber : SHORT -> 'int16_t'
// FieldIdentifier : SHORT -> 'int16_t'
// Value : void* -> 'void *'
// BufferLength : INT -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("ODBC32.dll", {
SQLSetDescField: { parameters: ["pointer", "i16", "i16", "pointer", "i32"], result: "i16" },
});
// lib.symbols.SQLSetDescField(DescriptorHandle, RecNumber, FieldIdentifier, Value, BufferLength)
// DescriptorHandle : void* in/out -> "pointer"
// RecNumber : SHORT -> "i16"
// FieldIdentifier : SHORT -> "i16"
// Value : void* -> "pointer"
// BufferLength : INT -> "i32"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int16_t SQLSetDescField(
void* DescriptorHandle,
int16_t RecNumber,
int16_t FieldIdentifier,
void* Value,
int32_t BufferLength);
C, "ODBC32.dll");
// $ffi->SQLSetDescField(DescriptorHandle, RecNumber, FieldIdentifier, Value, BufferLength);
// DescriptorHandle : void* in/out
// RecNumber : SHORT
// FieldIdentifier : SHORT
// Value : void*
// BufferLength : INT
// 構造体/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, W32APIOptions.ASCII_OPTIONS);
short SQLSetDescField(
Pointer DescriptorHandle, // void* in/out
short RecNumber, // SHORT
short FieldIdentifier, // SHORT
Pointer Value, // void*
int BufferLength // INT
);
}@[Link("odbc32")]
lib LibODBC32
fun SQLSetDescField = SQLSetDescField(
DescriptorHandle : Void*, # void* in/out
RecNumber : Int16, # SHORT
FieldIdentifier : Int16, # SHORT
Value : Void*, # void*
BufferLength : Int32 # INT
) : Int16
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef SQLSetDescFieldNative = Int16 Function(Pointer<Void>, Int16, Int16, Pointer<Void>, Int32);
typedef SQLSetDescFieldDart = int Function(Pointer<Void>, int, int, Pointer<Void>, int);
final SQLSetDescField = DynamicLibrary.open('ODBC32.dll')
.lookupFunction<SQLSetDescFieldNative, SQLSetDescFieldDart>('SQLSetDescField');
// DescriptorHandle : void* in/out -> Pointer<Void>
// RecNumber : SHORT -> Int16
// FieldIdentifier : SHORT -> Int16
// Value : void* -> Pointer<Void>
// BufferLength : INT -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SQLSetDescField(
DescriptorHandle: Pointer; // void* in/out
RecNumber: Smallint; // SHORT
FieldIdentifier: Smallint; // SHORT
Value: Pointer; // void*
BufferLength: Integer // INT
): Smallint; stdcall;
external 'ODBC32.dll' name 'SQLSetDescField';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SQLSetDescField"
c_SQLSetDescField :: Ptr () -> Int16 -> Int16 -> Ptr () -> Int32 -> IO Int16
-- DescriptorHandle : void* in/out -> Ptr ()
-- RecNumber : SHORT -> Int16
-- FieldIdentifier : SHORT -> Int16
-- Value : void* -> Ptr ()
-- BufferLength : INT -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let sqlsetdescfield =
foreign "SQLSetDescField"
((ptr void) @-> int16_t @-> int16_t @-> (ptr void) @-> int32_t @-> returning int16_t)
(* DescriptorHandle : void* in/out -> (ptr void) *)
(* RecNumber : SHORT -> int16_t *)
(* FieldIdentifier : SHORT -> int16_t *)
(* Value : void* -> (ptr void) *)
(* BufferLength : INT -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library odbc32 (t "ODBC32.dll"))
(cffi:use-foreign-library odbc32)
(cffi:defcfun ("SQLSetDescField" sqlset-desc-field :convention :stdcall) :int16
(descriptor-handle :pointer) ; void* in/out
(rec-number :int16) ; SHORT
(field-identifier :int16) ; SHORT
(value :pointer) ; void*
(buffer-length :int32)) ; INT
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SQLSetDescField = Win32::API::More->new('ODBC32',
'short SQLSetDescField(LPVOID DescriptorHandle, short RecNumber, short FieldIdentifier, LPVOID Value, int BufferLength)');
# my $ret = $SQLSetDescField->Call($DescriptorHandle, $RecNumber, $FieldIdentifier, $Value, $BufferLength);
# DescriptorHandle : void* in/out -> LPVOID
# RecNumber : SHORT -> short
# FieldIdentifier : SHORT -> short
# Value : void* -> LPVOID
# BufferLength : INT -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
文字セット違い
- f SQLSetDescFieldW (Unicode版) — 記述子レコードの指定フィールドに値を設定する(Unicode)。