ホーム › System.Search › SQLColAttributesA
SQLColAttributesA
関数結果セット列の記述属性を取得する(ANSI・非推奨)。
シグネチャ
// ODBC32.dll (ANSI / -A)
#include <windows.h>
SHORT SQLColAttributesA(
void* hstmt,
WORD icol,
WORD fDescType,
void* rgbDesc, // optional
SHORT cbDescMax,
SHORT* pcbDesc, // optional
INT* pfDesc // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hstmt | void* | inout | ODBCのステートメントハンドル。旧式の列属性取得対象。 |
| icol | WORD | in | 対象列番号。1始まりで指定する。 |
| fDescType | WORD | in | 取得したい記述子型。SQL_COLUMN_*定数を指定する。 |
| rgbDesc | void* | outoptional | 文字列属性を受け取るバッファ。出力用。 |
| cbDescMax | SHORT | in | rgbDescバッファのバイト長。 |
| pcbDesc | SHORT* | outoptional | 実際に返された文字列のバイト長を受け取るポインタ。 |
| pfDesc | INT* | outoptional | 数値属性を受け取るポインタ。整数属性が格納される。 |
戻り値の型: SHORT
各言語での呼び出し定義
// ODBC32.dll (ANSI / -A)
#include <windows.h>
SHORT SQLColAttributesA(
void* hstmt,
WORD icol,
WORD fDescType,
void* rgbDesc, // optional
SHORT cbDescMax,
SHORT* pcbDesc, // optional
INT* pfDesc // optional
);[DllImport("ODBC32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern short SQLColAttributesA(
IntPtr hstmt, // void* in/out
ushort icol, // WORD
ushort fDescType, // WORD
IntPtr rgbDesc, // void* optional, out
short cbDescMax, // SHORT
IntPtr pcbDesc, // SHORT* optional, out
IntPtr pfDesc // INT* optional, out
);<DllImport("ODBC32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function SQLColAttributesA(
hstmt As IntPtr, ' void* in/out
icol As UShort, ' WORD
fDescType As UShort, ' WORD
rgbDesc As IntPtr, ' void* optional, out
cbDescMax As Short, ' SHORT
pcbDesc As IntPtr, ' SHORT* optional, out
pfDesc As IntPtr ' INT* optional, out
) As Short
End Function' hstmt : void* in/out
' icol : WORD
' fDescType : WORD
' rgbDesc : void* optional, out
' cbDescMax : SHORT
' pcbDesc : SHORT* optional, out
' pfDesc : INT* optional, out
Declare PtrSafe Function SQLColAttributesA Lib "odbc32" ( _
ByVal hstmt As LongPtr, _
ByVal icol As Integer, _
ByVal fDescType As Integer, _
ByVal rgbDesc As LongPtr, _
ByVal cbDescMax As Integer, _
ByVal pcbDesc As LongPtr, _
ByVal pfDesc As LongPtr) As Integer
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SQLColAttributesA = ctypes.windll.odbc32.SQLColAttributesA
SQLColAttributesA.restype = ctypes.c_short
SQLColAttributesA.argtypes = [
ctypes.POINTER(None), # hstmt : void* in/out
ctypes.c_ushort, # icol : WORD
ctypes.c_ushort, # fDescType : WORD
ctypes.POINTER(None), # rgbDesc : void* optional, out
ctypes.c_short, # cbDescMax : SHORT
ctypes.POINTER(ctypes.c_short), # pcbDesc : SHORT* optional, out
ctypes.POINTER(ctypes.c_int), # pfDesc : INT* optional, out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ODBC32.dll')
SQLColAttributesA = Fiddle::Function.new(
lib['SQLColAttributesA'],
[
Fiddle::TYPE_VOIDP, # hstmt : void* in/out
-Fiddle::TYPE_SHORT, # icol : WORD
-Fiddle::TYPE_SHORT, # fDescType : WORD
Fiddle::TYPE_VOIDP, # rgbDesc : void* optional, out
Fiddle::TYPE_SHORT, # cbDescMax : SHORT
Fiddle::TYPE_VOIDP, # pcbDesc : SHORT* optional, out
Fiddle::TYPE_VOIDP, # pfDesc : INT* optional, out
],
Fiddle::TYPE_SHORT)#[link(name = "odbc32")]
extern "system" {
fn SQLColAttributesA(
hstmt: *mut (), // void* in/out
icol: u16, // WORD
fDescType: u16, // WORD
rgbDesc: *mut (), // void* optional, out
cbDescMax: i16, // SHORT
pcbDesc: *mut i16, // SHORT* optional, out
pfDesc: *mut i32 // INT* optional, out
) -> i16;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ODBC32.dll", CharSet = CharSet.Ansi)]
public static extern short SQLColAttributesA(IntPtr hstmt, ushort icol, ushort fDescType, IntPtr rgbDesc, short cbDescMax, IntPtr pcbDesc, IntPtr pfDesc);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ODBC32_SQLColAttributesA' -Namespace Win32 -PassThru
# $api::SQLColAttributesA(hstmt, icol, fDescType, rgbDesc, cbDescMax, pcbDesc, pfDesc)#uselib "ODBC32.dll"
#func global SQLColAttributesA "SQLColAttributesA" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; SQLColAttributesA hstmt, icol, fDescType, rgbDesc, cbDescMax, varptr(pcbDesc), varptr(pfDesc) ; 戻り値は stat
; hstmt : void* in/out -> "sptr"
; icol : WORD -> "sptr"
; fDescType : WORD -> "sptr"
; rgbDesc : void* optional, out -> "sptr"
; cbDescMax : SHORT -> "sptr"
; pcbDesc : SHORT* optional, out -> "sptr"
; pfDesc : INT* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "ODBC32.dll" #cfunc global SQLColAttributesA "SQLColAttributesA" sptr, int, int, sptr, int, var, var ; res = SQLColAttributesA(hstmt, icol, fDescType, rgbDesc, cbDescMax, pcbDesc, pfDesc) ; hstmt : void* in/out -> "sptr" ; icol : WORD -> "int" ; fDescType : WORD -> "int" ; rgbDesc : void* optional, out -> "sptr" ; cbDescMax : SHORT -> "int" ; pcbDesc : SHORT* optional, out -> "var" ; pfDesc : INT* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ODBC32.dll" #cfunc global SQLColAttributesA "SQLColAttributesA" sptr, int, int, sptr, int, sptr, sptr ; res = SQLColAttributesA(hstmt, icol, fDescType, rgbDesc, cbDescMax, varptr(pcbDesc), varptr(pfDesc)) ; hstmt : void* in/out -> "sptr" ; icol : WORD -> "int" ; fDescType : WORD -> "int" ; rgbDesc : void* optional, out -> "sptr" ; cbDescMax : SHORT -> "int" ; pcbDesc : SHORT* optional, out -> "sptr" ; pfDesc : INT* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; SHORT SQLColAttributesA(void* hstmt, WORD icol, WORD fDescType, void* rgbDesc, SHORT cbDescMax, SHORT* pcbDesc, INT* pfDesc) #uselib "ODBC32.dll" #cfunc global SQLColAttributesA "SQLColAttributesA" intptr, int, int, intptr, int, var, var ; res = SQLColAttributesA(hstmt, icol, fDescType, rgbDesc, cbDescMax, pcbDesc, pfDesc) ; hstmt : void* in/out -> "intptr" ; icol : WORD -> "int" ; fDescType : WORD -> "int" ; rgbDesc : void* optional, out -> "intptr" ; cbDescMax : SHORT -> "int" ; pcbDesc : SHORT* optional, out -> "var" ; pfDesc : INT* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; SHORT SQLColAttributesA(void* hstmt, WORD icol, WORD fDescType, void* rgbDesc, SHORT cbDescMax, SHORT* pcbDesc, INT* pfDesc) #uselib "ODBC32.dll" #cfunc global SQLColAttributesA "SQLColAttributesA" intptr, int, int, intptr, int, intptr, intptr ; res = SQLColAttributesA(hstmt, icol, fDescType, rgbDesc, cbDescMax, varptr(pcbDesc), varptr(pfDesc)) ; hstmt : void* in/out -> "intptr" ; icol : WORD -> "int" ; fDescType : WORD -> "int" ; rgbDesc : void* optional, out -> "intptr" ; cbDescMax : SHORT -> "int" ; pcbDesc : SHORT* optional, out -> "intptr" ; pfDesc : INT* optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
odbc32 = windows.NewLazySystemDLL("ODBC32.dll")
procSQLColAttributesA = odbc32.NewProc("SQLColAttributesA")
)
// hstmt (void* in/out), icol (WORD), fDescType (WORD), rgbDesc (void* optional, out), cbDescMax (SHORT), pcbDesc (SHORT* optional, out), pfDesc (INT* optional, out)
r1, _, err := procSQLColAttributesA.Call(
uintptr(hstmt),
uintptr(icol),
uintptr(fDescType),
uintptr(rgbDesc),
uintptr(cbDescMax),
uintptr(pcbDesc),
uintptr(pfDesc),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // SHORTfunction SQLColAttributesA(
hstmt: Pointer; // void* in/out
icol: Word; // WORD
fDescType: Word; // WORD
rgbDesc: Pointer; // void* optional, out
cbDescMax: Smallint; // SHORT
pcbDesc: Pointer; // SHORT* optional, out
pfDesc: Pointer // INT* optional, out
): Smallint; stdcall;
external 'ODBC32.dll' name 'SQLColAttributesA';result := DllCall("ODBC32\SQLColAttributesA"
, "Ptr", hstmt ; void* in/out
, "UShort", icol ; WORD
, "UShort", fDescType ; WORD
, "Ptr", rgbDesc ; void* optional, out
, "Short", cbDescMax ; SHORT
, "Ptr", pcbDesc ; SHORT* optional, out
, "Ptr", pfDesc ; INT* optional, out
, "Short") ; return: SHORT●SQLColAttributesA(hstmt, icol, fDescType, rgbDesc, cbDescMax, pcbDesc, pfDesc) = DLL("ODBC32.dll", "int SQLColAttributesA(void*, int, int, void*, int, void*, void*)")
# 呼び出し: SQLColAttributesA(hstmt, icol, fDescType, rgbDesc, cbDescMax, pcbDesc, pfDesc)
# hstmt : void* in/out -> "void*"
# icol : WORD -> "int"
# fDescType : WORD -> "int"
# rgbDesc : void* optional, out -> "void*"
# cbDescMax : SHORT -> "int"
# pcbDesc : SHORT* optional, out -> "void*"
# pfDesc : INT* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "odbc32" fn SQLColAttributesA(
hstmt: ?*anyopaque, // void* in/out
icol: u16, // WORD
fDescType: u16, // WORD
rgbDesc: ?*anyopaque, // void* optional, out
cbDescMax: i16, // SHORT
pcbDesc: [*c]i16, // SHORT* optional, out
pfDesc: [*c]i32 // INT* optional, out
) callconv(std.os.windows.WINAPI) i16;proc SQLColAttributesA(
hstmt: pointer, # void* in/out
icol: uint16, # WORD
fDescType: uint16, # WORD
rgbDesc: pointer, # void* optional, out
cbDescMax: int16, # SHORT
pcbDesc: ptr int16, # SHORT* optional, out
pfDesc: ptr int32 # INT* optional, out
): int16 {.importc: "SQLColAttributesA", stdcall, dynlib: "ODBC32.dll".}pragma(lib, "odbc32");
extern(Windows)
short SQLColAttributesA(
void* hstmt, // void* in/out
ushort icol, // WORD
ushort fDescType, // WORD
void* rgbDesc, // void* optional, out
short cbDescMax, // SHORT
short* pcbDesc, // SHORT* optional, out
int* pfDesc // INT* optional, out
);ccall((:SQLColAttributesA, "ODBC32.dll"), stdcall, Int16,
(Ptr{Cvoid}, UInt16, UInt16, Ptr{Cvoid}, Int16, Ptr{Int16}, Ptr{Int32}),
hstmt, icol, fDescType, rgbDesc, cbDescMax, pcbDesc, pfDesc)
# hstmt : void* in/out -> Ptr{Cvoid}
# icol : WORD -> UInt16
# fDescType : WORD -> UInt16
# rgbDesc : void* optional, out -> Ptr{Cvoid}
# cbDescMax : SHORT -> Int16
# pcbDesc : SHORT* optional, out -> Ptr{Int16}
# pfDesc : INT* optional, out -> Ptr{Int32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int16_t SQLColAttributesA(
void* hstmt,
uint16_t icol,
uint16_t fDescType,
void* rgbDesc,
int16_t cbDescMax,
int16_t* pcbDesc,
int32_t* pfDesc);
]]
local odbc32 = ffi.load("odbc32")
-- odbc32.SQLColAttributesA(hstmt, icol, fDescType, rgbDesc, cbDescMax, pcbDesc, pfDesc)
-- hstmt : void* in/out
-- icol : WORD
-- fDescType : WORD
-- rgbDesc : void* optional, out
-- cbDescMax : SHORT
-- pcbDesc : SHORT* optional, out
-- pfDesc : INT* optional, out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('ODBC32.dll');
const SQLColAttributesA = lib.func('__stdcall', 'SQLColAttributesA', 'int16_t', ['void *', 'uint16_t', 'uint16_t', 'void *', 'int16_t', 'int16_t *', 'int32_t *']);
// SQLColAttributesA(hstmt, icol, fDescType, rgbDesc, cbDescMax, pcbDesc, pfDesc)
// hstmt : void* in/out -> 'void *'
// icol : WORD -> 'uint16_t'
// fDescType : WORD -> 'uint16_t'
// rgbDesc : void* optional, out -> 'void *'
// cbDescMax : SHORT -> 'int16_t'
// pcbDesc : SHORT* optional, out -> 'int16_t *'
// pfDesc : INT* optional, out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("ODBC32.dll", {
SQLColAttributesA: { parameters: ["pointer", "u16", "u16", "pointer", "i16", "pointer", "pointer"], result: "i16" },
});
// lib.symbols.SQLColAttributesA(hstmt, icol, fDescType, rgbDesc, cbDescMax, pcbDesc, pfDesc)
// hstmt : void* in/out -> "pointer"
// icol : WORD -> "u16"
// fDescType : WORD -> "u16"
// rgbDesc : void* optional, out -> "pointer"
// cbDescMax : SHORT -> "i16"
// pcbDesc : SHORT* optional, out -> "pointer"
// pfDesc : INT* optional, out -> "pointer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int16_t SQLColAttributesA(
void* hstmt,
uint16_t icol,
uint16_t fDescType,
void* rgbDesc,
int16_t cbDescMax,
int16_t* pcbDesc,
int32_t* pfDesc);
C, "ODBC32.dll");
// $ffi->SQLColAttributesA(hstmt, icol, fDescType, rgbDesc, cbDescMax, pcbDesc, pfDesc);
// hstmt : void* in/out
// icol : WORD
// fDescType : WORD
// rgbDesc : void* optional, out
// cbDescMax : SHORT
// pcbDesc : SHORT* optional, out
// pfDesc : INT* optional, 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, W32APIOptions.ASCII_OPTIONS);
short SQLColAttributesA(
Pointer hstmt, // void* in/out
short icol, // WORD
short fDescType, // WORD
Pointer rgbDesc, // void* optional, out
short cbDescMax, // SHORT
ShortByReference pcbDesc, // SHORT* optional, out
IntByReference pfDesc // INT* optional, out
);
}@[Link("odbc32")]
lib LibODBC32
fun SQLColAttributesA = SQLColAttributesA(
hstmt : Void*, # void* in/out
icol : UInt16, # WORD
fDescType : UInt16, # WORD
rgbDesc : Void*, # void* optional, out
cbDescMax : Int16, # SHORT
pcbDesc : Int16*, # SHORT* optional, out
pfDesc : Int32* # INT* optional, out
) : Int16
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef SQLColAttributesANative = Int16 Function(Pointer<Void>, Uint16, Uint16, Pointer<Void>, Int16, Pointer<Int16>, Pointer<Int32>);
typedef SQLColAttributesADart = int Function(Pointer<Void>, int, int, Pointer<Void>, int, Pointer<Int16>, Pointer<Int32>);
final SQLColAttributesA = DynamicLibrary.open('ODBC32.dll')
.lookupFunction<SQLColAttributesANative, SQLColAttributesADart>('SQLColAttributesA');
// hstmt : void* in/out -> Pointer<Void>
// icol : WORD -> Uint16
// fDescType : WORD -> Uint16
// rgbDesc : void* optional, out -> Pointer<Void>
// cbDescMax : SHORT -> Int16
// pcbDesc : SHORT* optional, out -> Pointer<Int16>
// pfDesc : INT* optional, out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SQLColAttributesA(
hstmt: Pointer; // void* in/out
icol: Word; // WORD
fDescType: Word; // WORD
rgbDesc: Pointer; // void* optional, out
cbDescMax: Smallint; // SHORT
pcbDesc: Pointer; // SHORT* optional, out
pfDesc: Pointer // INT* optional, out
): Smallint; stdcall;
external 'ODBC32.dll' name 'SQLColAttributesA';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SQLColAttributesA"
c_SQLColAttributesA :: Ptr () -> Word16 -> Word16 -> Ptr () -> Int16 -> Ptr Int16 -> Ptr Int32 -> IO Int16
-- hstmt : void* in/out -> Ptr ()
-- icol : WORD -> Word16
-- fDescType : WORD -> Word16
-- rgbDesc : void* optional, out -> Ptr ()
-- cbDescMax : SHORT -> Int16
-- pcbDesc : SHORT* optional, out -> Ptr Int16
-- pfDesc : INT* optional, out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let sqlcolattributesa =
foreign "SQLColAttributesA"
((ptr void) @-> uint16_t @-> uint16_t @-> (ptr void) @-> int16_t @-> (ptr int16_t) @-> (ptr int32_t) @-> returning int16_t)
(* hstmt : void* in/out -> (ptr void) *)
(* icol : WORD -> uint16_t *)
(* fDescType : WORD -> uint16_t *)
(* rgbDesc : void* optional, out -> (ptr void) *)
(* cbDescMax : SHORT -> int16_t *)
(* pcbDesc : SHORT* optional, out -> (ptr int16_t) *)
(* pfDesc : INT* optional, 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 ("SQLColAttributesA" sqlcol-attributes-a :convention :stdcall) :int16
(hstmt :pointer) ; void* in/out
(icol :uint16) ; WORD
(f-desc-type :uint16) ; WORD
(rgb-desc :pointer) ; void* optional, out
(cb-desc-max :int16) ; SHORT
(pcb-desc :pointer) ; SHORT* optional, out
(pf-desc :pointer)) ; INT* optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SQLColAttributesA = Win32::API::More->new('ODBC32',
'short SQLColAttributesA(LPVOID hstmt, WORD icol, WORD fDescType, LPVOID rgbDesc, short cbDescMax, LPVOID pcbDesc, LPVOID pfDesc)');
# my $ret = $SQLColAttributesA->Call($hstmt, $icol, $fDescType, $rgbDesc, $cbDescMax, $pcbDesc, $pfDesc);
# hstmt : void* in/out -> LPVOID
# icol : WORD -> WORD
# fDescType : WORD -> WORD
# rgbDesc : void* optional, out -> LPVOID
# cbDescMax : SHORT -> short
# pcbDesc : SHORT* optional, out -> LPVOID
# pfDesc : INT* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
文字セット違い
- f SQLColAttributesW (Unicode版) — 結果セット列の記述属性を取得する(Unicode・非推奨)。