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

SQLGetFunctions

関数
ドライバが特定のODBC関数を対応するか問い合わせる。
DLLODBC32.dll呼出規約winapi

シグネチャ

// ODBC32.dll
#include <windows.h>

SHORT SQLGetFunctions(
    void* ConnectionHandle,
    WORD FunctionId,
    WORD* Supported   // optional
);

パラメーター

名前型方向説明
ConnectionHandlevoid*inout[入力] 接続ハンドル。
FunctionIdWORDin

[入力] 対象となる ODBC 関数を識別する #define 値、または SQL_API_ODBC3_ALL_FUNCTIONS orSQL_API_ALL_FUNCTIONS。SQL_API_ODBC3_ALL_FUNCTIONS は、ODBC 3*.x* アプリケーションが ODBC 3*.x* 以前の関数のサポート状況を判別するために使用します。SQL_API_ALL_FUNCTIONS は、ODBC 2*.x* アプリケーションが ODBC 2*.x* 以前の関数のサポート状況を判別するために使用します。

ODBC 関数を識別する #define 値の一覧については、「解説」の表を参照してください。

SupportedWORD*outoptional当該関数のサポート有無を受け取るポインタ。TRUE/FALSEまたはビット配列。

戻り値の型: SHORT

公式ドキュメント

SQLGetFunctions は、ドライバーが特定の ODBC 関数をサポートしているかどうかに関する情報を返します。この関数はドライバーマネージャーに実装されていますが、ドライバーに実装することもできます。ドライバーが SQLGetFunctions を実装している場合、ドライバーマネージャーはドライバー内のその関数を呼び出します。実装していない場合は、ドライバーマネージャー自身が関数を実行します。

戻り値

SQL_SUCCESS、SQL_SUCCESS_WITH_INFO、SQL_ERROR、または SQL_INVALID_HANDLE。

解説(Remarks)

SQLGetFunctions は、SQLGetFunctions、SQLDataSources、および SQLDrivers については、常にサポートされていると返します。これは、これらの関数がドライバーマネージャーに実装されているためです。ドライバーマネージャーは、対応する Unicode 関数が存在する場合は ANSI 関数を Unicode 関数にマップし、対応する ANSI 関数が存在する場合は Unicode 関数を ANSI 関数にマップします。アプリケーションが SQLGetFunctions をどのように使用するかについては、Interface Conformance Levels を参照してください。

ISO 92 標準準拠レベルに準拠する関数について、FunctionId に指定できる有効な値の一覧を次に示します。

FunctionId の値 FunctionId の値
SQL_API_SQLALLOCHANDLE SQL_API_SQLGETDESCFIELD
SQL_API_SQLBINDCOL SQL_API_SQLGETDESCREC
SQL_API_SQLCANCEL SQL_API_SQLGETDIAGFIELD
SQL_API_SQLCLOSECURSOR SQL_API_SQLGETDIAGREC
SQL_API_SQLCOLATTRIBUTE SQL_API_SQLGETENVATTR
SQL_API_SQLCONNECT SQL_API_SQLGETFUNCTIONS
SQL_API_SQLCOPYDESC SQL_API_SQLGETINFO
SQL_API_SQLDATASOURCES SQL_API_SQLGETSTMTATTR
SQL_API_SQLDESCRIBECOL SQL_API_SQLGETTYPEINFO
SQL_API_SQLDISCONNECT SQL_API_SQLNUMRESULTCOLS
SQL_API_SQLDRIVERS SQL_API_SQLPARAMDATA
SQL_API_SQLENDTRAN SQL_API_SQLPREPARE
SQL_API_SQLEXECDIRECT SQL_API_SQLPUTDATA
SQL_API_SQLEXECUTE SQL_API_SQLROWCOUNT
SQL_API_SQLFETCH SQL_API_SQLSETCONNECTATTR
SQL_API_SQLFETCHSCROLL SQL_API_SQLSETCURSORNAME
SQL_API_SQLFREEHANDLE SQL_API_SQLSETDESCFIELD
SQL_API_SQLFREESTMT SQL_API_SQLSETDESCREC
SQL_API_SQLGETCONNECTATTR SQL_API_SQLSETENVATTR
SQL_API_SQLGETCURSORNAME SQL_API_SQLSETSTMTATTR
SQL_API_SQLGETDATA

Open Group 標準準拠レベルに準拠する関数について、FunctionId に指定できる有効な値の一覧を次に示します。

FunctionId の値 FunctionId の値
SQL_API_SQLCOLUMNS SQL_API_SQLSTATISTICS
SQL_API_SQLSPECIALCOLUMNS SQL_API_SQLTABLES

ODBC 標準準拠レベルに準拠する関数について、FunctionId に指定できる有効な値の一覧を次に示します。

FunctionId の値 FunctionId の値
SQL_API_SQLBINDPARAMETER SQL_API_SQLNATIVESQL
SQL_API_SQLBROWSECONNECT SQL_API_SQLNUMPARAMS
SQL_API_SQLBULKOPERATIONS[1] SQL_API_SQLPRIMARYKEYS
SQL_API_SQLCOLUMNPRIVILEGES SQL_API_SQLPROCEDURECOLUMNS
SQL_API_SQLDESCRIBEPARAM SQL_API_SQLPROCEDURES
SQL_API_SQLDRIVERCONNECT SQL_API_SQLSETPOS
SQL_API_SQLFOREIGNKEYS SQL_API_SQLTABLEPRIVILEGES
SQL_API_SQLMORERESULTS

[1] ODBC 2*.x* ドライバーを使用する場合、SQLBulkOperations は、次の両方が真である場合にのみサポートされていると返されます。すなわち、ODBC 2*.x* ドライバーが SQLSetPos をサポートしていること、および情報型 SQL_POS_OPERATIONS が SQL_POS_ADD ビットをセットして返すことです。

ODBC 3.8 以降で導入された関数について、FunctionId に指定できる有効な値の一覧を次に示します。

FunctionId の値
SQL_API_SQLCANCELHANDLE [2]

[2] SQLCancelHandle は、ドライバーが SQLCancel と SQLCancelHandle の両方をサポートしている場合にのみサポートされていると返されます。SQLCancel はサポートされていても SQLCancelHandle がサポートされていない場合、アプリケーションはステートメントハンドルに対して SQLCancelHandle を呼び出すことができます。SQLCancel にマップされるためです。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp)

各言語での呼び出し定義

// ODBC32.dll
#include <windows.h>

SHORT SQLGetFunctions(
    void* ConnectionHandle,
    WORD FunctionId,
    WORD* Supported   // optional
);
[DllImport("ODBC32.dll", ExactSpelling = true)]
static extern short SQLGetFunctions(
    IntPtr ConnectionHandle,   // void* in/out
    ushort FunctionId,   // WORD
    IntPtr Supported   // WORD* optional, out
);
<DllImport("ODBC32.dll", ExactSpelling:=True)>
Public Shared Function SQLGetFunctions(
    ConnectionHandle As IntPtr,   ' void* in/out
    FunctionId As UShort,   ' WORD
    Supported As IntPtr   ' WORD* optional, out
) As Short
End Function
' ConnectionHandle : void* in/out
' FunctionId : WORD
' Supported : WORD* optional, out
Declare PtrSafe Function SQLGetFunctions Lib "odbc32" ( _
    ByVal ConnectionHandle As LongPtr, _
    ByVal FunctionId As Integer, _
    ByVal Supported As LongPtr) As Integer
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SQLGetFunctions = ctypes.windll.odbc32.SQLGetFunctions
SQLGetFunctions.restype = ctypes.c_short
SQLGetFunctions.argtypes = [
    ctypes.POINTER(None),  # ConnectionHandle : void* in/out
    ctypes.c_ushort,  # FunctionId : WORD
    ctypes.POINTER(ctypes.c_ushort),  # Supported : WORD* optional, out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	odbc32 = windows.NewLazySystemDLL("ODBC32.dll")
	procSQLGetFunctions = odbc32.NewProc("SQLGetFunctions")
)

// ConnectionHandle (void* in/out), FunctionId (WORD), Supported (WORD* optional, out)
r1, _, err := procSQLGetFunctions.Call(
	uintptr(ConnectionHandle),
	uintptr(FunctionId),
	uintptr(Supported),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // SHORT
function SQLGetFunctions(
  ConnectionHandle: Pointer;   // void* in/out
  FunctionId: Word;   // WORD
  Supported: Pointer   // WORD* optional, out
): Smallint; stdcall;
  external 'ODBC32.dll' name 'SQLGetFunctions';
result := DllCall("ODBC32\SQLGetFunctions"
    , "Ptr", ConnectionHandle   ; void* in/out
    , "UShort", FunctionId   ; WORD
    , "Ptr", Supported   ; WORD* optional, out
    , "Short")   ; return: SHORT
●SQLGetFunctions(ConnectionHandle, FunctionId, Supported) = DLL("ODBC32.dll", "int SQLGetFunctions(void*, int, void*)")
# 呼び出し: SQLGetFunctions(ConnectionHandle, FunctionId, Supported)
# ConnectionHandle : void* in/out -> "void*"
# FunctionId : WORD -> "int"
# Supported : WORD* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "odbc32" fn SQLGetFunctions(
    ConnectionHandle: ?*anyopaque, // void* in/out
    FunctionId: u16, // WORD
    Supported: [*c]u16 // WORD* optional, out
) callconv(std.os.windows.WINAPI) i16;
proc SQLGetFunctions(
    ConnectionHandle: pointer,  # void* in/out
    FunctionId: uint16,  # WORD
    Supported: ptr uint16  # WORD* optional, out
): int16 {.importc: "SQLGetFunctions", stdcall, dynlib: "ODBC32.dll".}
pragma(lib, "odbc32");
extern(Windows)
short SQLGetFunctions(
    void* ConnectionHandle,   // void* in/out
    ushort FunctionId,   // WORD
    ushort* Supported   // WORD* optional, out
);
ccall((:SQLGetFunctions, "ODBC32.dll"), stdcall, Int16,
      (Ptr{Cvoid}, UInt16, Ptr{UInt16}),
      ConnectionHandle, FunctionId, Supported)
# ConnectionHandle : void* in/out -> Ptr{Cvoid}
# FunctionId : WORD -> UInt16
# Supported : WORD* optional, out -> Ptr{UInt16}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int16_t SQLGetFunctions(
    void* ConnectionHandle,
    uint16_t FunctionId,
    uint16_t* Supported);
]]
local odbc32 = ffi.load("odbc32")
-- odbc32.SQLGetFunctions(ConnectionHandle, FunctionId, Supported)
-- ConnectionHandle : void* in/out
-- FunctionId : WORD
-- Supported : WORD* optional, out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('ODBC32.dll');
const SQLGetFunctions = lib.func('__stdcall', 'SQLGetFunctions', 'int16_t', ['void *', 'uint16_t', 'uint16_t *']);
// SQLGetFunctions(ConnectionHandle, FunctionId, Supported)
// ConnectionHandle : void* in/out -> 'void *'
// FunctionId : WORD -> 'uint16_t'
// Supported : WORD* optional, out -> 'uint16_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("ODBC32.dll", {
  SQLGetFunctions: { parameters: ["pointer", "u16", "pointer"], result: "i16" },
});
// lib.symbols.SQLGetFunctions(ConnectionHandle, FunctionId, Supported)
// ConnectionHandle : void* in/out -> "pointer"
// FunctionId : WORD -> "u16"
// Supported : WORD* optional, out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int16_t SQLGetFunctions(
    void* ConnectionHandle,
    uint16_t FunctionId,
    uint16_t* Supported);
C, "ODBC32.dll");
// $ffi->SQLGetFunctions(ConnectionHandle, FunctionId, Supported);
// ConnectionHandle : void* in/out
// FunctionId : WORD
// Supported : WORD* 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);
    short SQLGetFunctions(
        Pointer ConnectionHandle,   // void* in/out
        short FunctionId,   // WORD
        ShortByReference Supported   // WORD* optional, out
    );
}
@[Link("odbc32")]
lib LibODBC32
  fun SQLGetFunctions = SQLGetFunctions(
    ConnectionHandle : Void*,   # void* in/out
    FunctionId : UInt16,   # WORD
    Supported : UInt16*   # WORD* 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 SQLGetFunctionsNative = Int16 Function(Pointer<Void>, Uint16, Pointer<Uint16>);
typedef SQLGetFunctionsDart = int Function(Pointer<Void>, int, Pointer<Uint16>);
final SQLGetFunctions = DynamicLibrary.open('ODBC32.dll')
    .lookupFunction<SQLGetFunctionsNative, SQLGetFunctionsDart>('SQLGetFunctions');
// ConnectionHandle : void* in/out -> Pointer<Void>
// FunctionId : WORD -> Uint16
// Supported : WORD* optional, out -> Pointer<Uint16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function SQLGetFunctions(
  ConnectionHandle: Pointer;   // void* in/out
  FunctionId: Word;   // WORD
  Supported: Pointer   // WORD* optional, out
): Smallint; stdcall;
  external 'ODBC32.dll' name 'SQLGetFunctions';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "SQLGetFunctions"
  c_SQLGetFunctions :: Ptr () -> Word16 -> Ptr Word16 -> IO Int16
-- ConnectionHandle : void* in/out -> Ptr ()
-- FunctionId : WORD -> Word16
-- Supported : WORD* optional, out -> Ptr Word16
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let sqlgetfunctions =
  foreign "SQLGetFunctions"
    ((ptr void) @-> uint16_t @-> (ptr uint16_t) @-> returning int16_t)
(* ConnectionHandle : void* in/out -> (ptr void) *)
(* FunctionId : WORD -> uint16_t *)
(* Supported : WORD* optional, out -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library odbc32 (t "ODBC32.dll"))
(cffi:use-foreign-library odbc32)

(cffi:defcfun ("SQLGetFunctions" sqlget-functions :convention :stdcall) :int16
  (connection-handle :pointer)   ; void* in/out
  (function-id :uint16)   ; WORD
  (supported :pointer))   ; WORD* optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $SQLGetFunctions = Win32::API::More->new('ODBC32',
    'short SQLGetFunctions(LPVOID ConnectionHandle, WORD FunctionId, LPVOID Supported)');
# my $ret = $SQLGetFunctions->Call($ConnectionHandle, $FunctionId, $Supported);
# ConnectionHandle : void* in/out -> LPVOID
# FunctionId : WORD -> WORD
# Supported : WORD* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。