Win32 API 日本語リファレンス
ホームSystem.Search › SQLGetDescRec

SQLGetDescRec

関数
記述子レコードの複数フィールド値をまとめて取得する。
DLLODBC32.dll文字セットANSI (-A)呼出規約winapi

シグネチャ

// ODBC32.dll  (ANSI / -A)
#include <windows.h>

SHORT SQLGetDescRec(
    void* DescriptorHandle,
    SHORT RecNumber,
    BYTE* Name,   // optional
    SHORT BufferLength,
    SHORT* StringLengthPtr,   // optional
    SHORT* TypePtr,   // optional
    SHORT* SubTypePtr,   // optional
    INT* LengthPtr,   // optional
    SHORT* PrecisionPtr,   // optional
    SHORT* ScalePtr,   // optional
    SHORT* NullablePtr   // optional
);

パラメーター

名前方向
DescriptorHandlevoid*inout
RecNumberSHORTin
NameBYTE*outoptional
BufferLengthSHORTin
StringLengthPtrSHORT*outoptional
TypePtrSHORT*outoptional
SubTypePtrSHORT*outoptional
LengthPtrINT*outoptional
PrecisionPtrSHORT*outoptional
ScalePtrSHORT*outoptional
NullablePtrSHORT*outoptional

戻り値の型: SHORT

各言語での呼び出し定義

// ODBC32.dll  (ANSI / -A)
#include <windows.h>

SHORT SQLGetDescRec(
    void* DescriptorHandle,
    SHORT RecNumber,
    BYTE* Name,   // optional
    SHORT BufferLength,
    SHORT* StringLengthPtr,   // optional
    SHORT* TypePtr,   // optional
    SHORT* SubTypePtr,   // optional
    INT* LengthPtr,   // optional
    SHORT* PrecisionPtr,   // optional
    SHORT* ScalePtr,   // optional
    SHORT* NullablePtr   // optional
);
[DllImport("ODBC32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern short SQLGetDescRec(
    IntPtr DescriptorHandle,   // void* in/out
    short RecNumber,   // SHORT
    IntPtr Name,   // BYTE* optional, out
    short BufferLength,   // SHORT
    IntPtr StringLengthPtr,   // SHORT* optional, out
    IntPtr TypePtr,   // SHORT* optional, out
    IntPtr SubTypePtr,   // SHORT* optional, out
    IntPtr LengthPtr,   // INT* optional, out
    IntPtr PrecisionPtr,   // SHORT* optional, out
    IntPtr ScalePtr,   // SHORT* optional, out
    IntPtr NullablePtr   // SHORT* optional, out
);
<DllImport("ODBC32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function SQLGetDescRec(
    DescriptorHandle As IntPtr,   ' void* in/out
    RecNumber As Short,   ' SHORT
    Name As IntPtr,   ' BYTE* optional, out
    BufferLength As Short,   ' SHORT
    StringLengthPtr As IntPtr,   ' SHORT* optional, out
    TypePtr As IntPtr,   ' SHORT* optional, out
    SubTypePtr As IntPtr,   ' SHORT* optional, out
    LengthPtr As IntPtr,   ' INT* optional, out
    PrecisionPtr As IntPtr,   ' SHORT* optional, out
    ScalePtr As IntPtr,   ' SHORT* optional, out
    NullablePtr As IntPtr   ' SHORT* optional, out
) As Short
End Function
' DescriptorHandle : void* in/out
' RecNumber : SHORT
' Name : BYTE* optional, out
' BufferLength : SHORT
' StringLengthPtr : SHORT* optional, out
' TypePtr : SHORT* optional, out
' SubTypePtr : SHORT* optional, out
' LengthPtr : INT* optional, out
' PrecisionPtr : SHORT* optional, out
' ScalePtr : SHORT* optional, out
' NullablePtr : SHORT* optional, out
Declare PtrSafe Function SQLGetDescRec Lib "odbc32" ( _
    ByVal DescriptorHandle As LongPtr, _
    ByVal RecNumber As Integer, _
    ByVal Name As LongPtr, _
    ByVal BufferLength As Integer, _
    ByVal StringLengthPtr As LongPtr, _
    ByVal TypePtr As LongPtr, _
    ByVal SubTypePtr As LongPtr, _
    ByVal LengthPtr As LongPtr, _
    ByVal PrecisionPtr As LongPtr, _
    ByVal ScalePtr As LongPtr, _
    ByVal NullablePtr As LongPtr) As Integer
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SQLGetDescRec = ctypes.windll.odbc32.SQLGetDescRec
SQLGetDescRec.restype = ctypes.c_short
SQLGetDescRec.argtypes = [
    ctypes.POINTER(None),  # DescriptorHandle : void* in/out
    ctypes.c_short,  # RecNumber : SHORT
    ctypes.POINTER(ctypes.c_ubyte),  # Name : BYTE* optional, out
    ctypes.c_short,  # BufferLength : SHORT
    ctypes.POINTER(ctypes.c_short),  # StringLengthPtr : SHORT* optional, out
    ctypes.POINTER(ctypes.c_short),  # TypePtr : SHORT* optional, out
    ctypes.POINTER(ctypes.c_short),  # SubTypePtr : SHORT* optional, out
    ctypes.POINTER(ctypes.c_int),  # LengthPtr : INT* optional, out
    ctypes.POINTER(ctypes.c_short),  # PrecisionPtr : SHORT* optional, out
    ctypes.POINTER(ctypes.c_short),  # ScalePtr : SHORT* optional, out
    ctypes.POINTER(ctypes.c_short),  # NullablePtr : SHORT* optional, out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('ODBC32.dll')
SQLGetDescRec = Fiddle::Function.new(
  lib['SQLGetDescRec'],
  [
    Fiddle::TYPE_VOIDP,  # DescriptorHandle : void* in/out
    Fiddle::TYPE_SHORT,  # RecNumber : SHORT
    Fiddle::TYPE_VOIDP,  # Name : BYTE* optional, out
    Fiddle::TYPE_SHORT,  # BufferLength : SHORT
    Fiddle::TYPE_VOIDP,  # StringLengthPtr : SHORT* optional, out
    Fiddle::TYPE_VOIDP,  # TypePtr : SHORT* optional, out
    Fiddle::TYPE_VOIDP,  # SubTypePtr : SHORT* optional, out
    Fiddle::TYPE_VOIDP,  # LengthPtr : INT* optional, out
    Fiddle::TYPE_VOIDP,  # PrecisionPtr : SHORT* optional, out
    Fiddle::TYPE_VOIDP,  # ScalePtr : SHORT* optional, out
    Fiddle::TYPE_VOIDP,  # NullablePtr : SHORT* optional, out
  ],
  Fiddle::TYPE_SHORT)
#[link(name = "odbc32")]
extern "system" {
    fn SQLGetDescRec(
        DescriptorHandle: *mut (),  // void* in/out
        RecNumber: i16,  // SHORT
        Name: *mut u8,  // BYTE* optional, out
        BufferLength: i16,  // SHORT
        StringLengthPtr: *mut i16,  // SHORT* optional, out
        TypePtr: *mut i16,  // SHORT* optional, out
        SubTypePtr: *mut i16,  // SHORT* optional, out
        LengthPtr: *mut i32,  // INT* optional, out
        PrecisionPtr: *mut i16,  // SHORT* optional, out
        ScalePtr: *mut i16,  // SHORT* optional, out
        NullablePtr: *mut i16  // SHORT* optional, out
    ) -> i16;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("ODBC32.dll", CharSet = CharSet.Ansi)]
public static extern short SQLGetDescRec(IntPtr DescriptorHandle, short RecNumber, IntPtr Name, short BufferLength, IntPtr StringLengthPtr, IntPtr TypePtr, IntPtr SubTypePtr, IntPtr LengthPtr, IntPtr PrecisionPtr, IntPtr ScalePtr, IntPtr NullablePtr);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ODBC32_SQLGetDescRec' -Namespace Win32 -PassThru
# $api::SQLGetDescRec(DescriptorHandle, RecNumber, Name, BufferLength, StringLengthPtr, TypePtr, SubTypePtr, LengthPtr, PrecisionPtr, ScalePtr, NullablePtr)
#uselib "ODBC32.dll"
#func global SQLGetDescRec "SQLGetDescRec" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; SQLGetDescRec DescriptorHandle, RecNumber, varptr(Name), BufferLength, varptr(StringLengthPtr), varptr(TypePtr), varptr(SubTypePtr), varptr(LengthPtr), varptr(PrecisionPtr), varptr(ScalePtr), varptr(NullablePtr)   ; 戻り値は stat
; DescriptorHandle : void* in/out -> "sptr"
; RecNumber : SHORT -> "sptr"
; Name : BYTE* optional, out -> "sptr"
; BufferLength : SHORT -> "sptr"
; StringLengthPtr : SHORT* optional, out -> "sptr"
; TypePtr : SHORT* optional, out -> "sptr"
; SubTypePtr : SHORT* optional, out -> "sptr"
; LengthPtr : INT* optional, out -> "sptr"
; PrecisionPtr : SHORT* optional, out -> "sptr"
; ScalePtr : SHORT* optional, out -> "sptr"
; NullablePtr : SHORT* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "ODBC32.dll"
#cfunc global SQLGetDescRec "SQLGetDescRec" sptr, int, var, int, var, var, var, var, var, var, var
; res = SQLGetDescRec(DescriptorHandle, RecNumber, Name, BufferLength, StringLengthPtr, TypePtr, SubTypePtr, LengthPtr, PrecisionPtr, ScalePtr, NullablePtr)
; DescriptorHandle : void* in/out -> "sptr"
; RecNumber : SHORT -> "int"
; Name : BYTE* optional, out -> "var"
; BufferLength : SHORT -> "int"
; StringLengthPtr : SHORT* optional, out -> "var"
; TypePtr : SHORT* optional, out -> "var"
; SubTypePtr : SHORT* optional, out -> "var"
; LengthPtr : INT* optional, out -> "var"
; PrecisionPtr : SHORT* optional, out -> "var"
; ScalePtr : SHORT* optional, out -> "var"
; NullablePtr : SHORT* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; SHORT SQLGetDescRec(void* DescriptorHandle, SHORT RecNumber, BYTE* Name, SHORT BufferLength, SHORT* StringLengthPtr, SHORT* TypePtr, SHORT* SubTypePtr, INT* LengthPtr, SHORT* PrecisionPtr, SHORT* ScalePtr, SHORT* NullablePtr)
#uselib "ODBC32.dll"
#cfunc global SQLGetDescRec "SQLGetDescRec" intptr, int, var, int, var, var, var, var, var, var, var
; res = SQLGetDescRec(DescriptorHandle, RecNumber, Name, BufferLength, StringLengthPtr, TypePtr, SubTypePtr, LengthPtr, PrecisionPtr, ScalePtr, NullablePtr)
; DescriptorHandle : void* in/out -> "intptr"
; RecNumber : SHORT -> "int"
; Name : BYTE* optional, out -> "var"
; BufferLength : SHORT -> "int"
; StringLengthPtr : SHORT* optional, out -> "var"
; TypePtr : SHORT* optional, out -> "var"
; SubTypePtr : SHORT* optional, out -> "var"
; LengthPtr : INT* optional, out -> "var"
; PrecisionPtr : SHORT* optional, out -> "var"
; ScalePtr : SHORT* optional, out -> "var"
; NullablePtr : SHORT* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	odbc32 = windows.NewLazySystemDLL("ODBC32.dll")
	procSQLGetDescRec = odbc32.NewProc("SQLGetDescRec")
)

// DescriptorHandle (void* in/out), RecNumber (SHORT), Name (BYTE* optional, out), BufferLength (SHORT), StringLengthPtr (SHORT* optional, out), TypePtr (SHORT* optional, out), SubTypePtr (SHORT* optional, out), LengthPtr (INT* optional, out), PrecisionPtr (SHORT* optional, out), ScalePtr (SHORT* optional, out), NullablePtr (SHORT* optional, out)
r1, _, err := procSQLGetDescRec.Call(
	uintptr(DescriptorHandle),
	uintptr(RecNumber),
	uintptr(Name),
	uintptr(BufferLength),
	uintptr(StringLengthPtr),
	uintptr(TypePtr),
	uintptr(SubTypePtr),
	uintptr(LengthPtr),
	uintptr(PrecisionPtr),
	uintptr(ScalePtr),
	uintptr(NullablePtr),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // SHORT
function SQLGetDescRec(
  DescriptorHandle: Pointer;   // void* in/out
  RecNumber: Smallint;   // SHORT
  Name: Pointer;   // BYTE* optional, out
  BufferLength: Smallint;   // SHORT
  StringLengthPtr: Pointer;   // SHORT* optional, out
  TypePtr: Pointer;   // SHORT* optional, out
  SubTypePtr: Pointer;   // SHORT* optional, out
  LengthPtr: Pointer;   // INT* optional, out
  PrecisionPtr: Pointer;   // SHORT* optional, out
  ScalePtr: Pointer;   // SHORT* optional, out
  NullablePtr: Pointer   // SHORT* optional, out
): Smallint; stdcall;
  external 'ODBC32.dll' name 'SQLGetDescRec';
result := DllCall("ODBC32\SQLGetDescRec"
    , "Ptr", DescriptorHandle   ; void* in/out
    , "Short", RecNumber   ; SHORT
    , "Ptr", Name   ; BYTE* optional, out
    , "Short", BufferLength   ; SHORT
    , "Ptr", StringLengthPtr   ; SHORT* optional, out
    , "Ptr", TypePtr   ; SHORT* optional, out
    , "Ptr", SubTypePtr   ; SHORT* optional, out
    , "Ptr", LengthPtr   ; INT* optional, out
    , "Ptr", PrecisionPtr   ; SHORT* optional, out
    , "Ptr", ScalePtr   ; SHORT* optional, out
    , "Ptr", NullablePtr   ; SHORT* optional, out
    , "Short")   ; return: SHORT
●SQLGetDescRec(DescriptorHandle, RecNumber, Name, BufferLength, StringLengthPtr, TypePtr, SubTypePtr, LengthPtr, PrecisionPtr, ScalePtr, NullablePtr) = DLL("ODBC32.dll", "int SQLGetDescRec(void*, int, void*, int, void*, void*, void*, void*, void*, void*, void*)")
# 呼び出し: SQLGetDescRec(DescriptorHandle, RecNumber, Name, BufferLength, StringLengthPtr, TypePtr, SubTypePtr, LengthPtr, PrecisionPtr, ScalePtr, NullablePtr)
# DescriptorHandle : void* in/out -> "void*"
# RecNumber : SHORT -> "int"
# Name : BYTE* optional, out -> "void*"
# BufferLength : SHORT -> "int"
# StringLengthPtr : SHORT* optional, out -> "void*"
# TypePtr : SHORT* optional, out -> "void*"
# SubTypePtr : SHORT* optional, out -> "void*"
# LengthPtr : INT* optional, out -> "void*"
# PrecisionPtr : SHORT* optional, out -> "void*"
# ScalePtr : SHORT* optional, out -> "void*"
# NullablePtr : SHORT* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。