Call Level Interface Guide and Reference

SQLGetFunctions - Get Functions

Purpose


Specification: DB2 CLI 2.1 ODBC 1.0 ISO CLI

SQLGetFunctions() to query whether a specific function is supported. This allows applications to adapt to varying levels of support when connecting to different database servers.

A connection to a database server must exist before calling this function.

Syntax

SQLRETURN   SQLGetFunctions  (
                SQLHDBC           ConnectionHandle,  /* hdbc */
                SQLUSMALLINT      FunctionId,        /* fFunction */
                SQLUSMALLINT *FAR SupportedPtr);     /* pfExists */

Function Arguments

Table 109. SQLGetFunctions Arguments
Data Type Argument Use Description
SQLHDBC ConnectionHandle input Database connection handle.
SQLUSMALLINT FunctionId input The function being queried. Valid FunctionId values are shown in Figure 17
SQLUSMALLINT * SupportedPtr output Pointer to location where this function will return SQL_TRUE or SQL_FALSE depending on whether the function being queried is supported.

Usage

Figure 17 shows the valid values for the FunctionId argument and whether the corresponding function is supported. (This list was generated using the sample application getfuncs.c.)

If FunctionId is set to SQL_API_ALL_FUNCTIONS, then SupportedPtr must point to an SQLSMALLINT array of 100 elements. The array is indexed by the FunctionId values used to identify many of the functions. Some elements of the array are unused and reserved. Since some FunctionId values are greater than 100, the array method can not be used to obtain a list of functions. The SQLGetFunction() call must be explicitly issued for all FunctionId values equal to or above 100. The complete set of FunctionId values is defined in sqlcli1.h.

Figure 17. Supported Functions list (output from getfuncs.c).

-------------------------------------------
Connected to Server: SAMPLE
 Database Name: SAMPLE
 Instance Name: db2inst1
     DBMS Name: DB2/6000
  DBMS Version: 05.00.0000
-------------------------------------------
SQLALLOCCONNECT      is supported   SQLALLOCENV          is supported
SQLALLOCHANDLE       is supported   SQLALLOCSTMT         is supported
SQLBINDCOL           is supported   SQLBINDFILETOCOL     is supported
SQLBINDFILETOPARAM   is supported   SQLBINDPARAM         is supported
SQLBINDPARAMETER     is supported   SQLBROWSECONNECT     is supported
SQLCANCEL            is supported   SQLCLOSECURSOR       is supported
SQLCOLATTRIBUTE      is supported   SQLCOLATTRIBUTES     is supported
SQLCOLUMNPRIVILEGES  is supported   SQLCOLUMNS           is supported
SQLCONNECT           is supported   SQLCOPYDESC          is supported
SQLDATASOURCES       is supported   SQLDESCRIBECOL       is supported
SQLDESCRIBEPARAM     is supported   SQLDISCONNECT        is supported
SQLDRIVERCONNECT     is supported   SQLENDTRAN           is supported
SQLERROR             is supported   SQLEXECDIRECT        is supported
SQLEXECUTE           is supported   SQLEXTENDEDFETCH     is supported
SQLFETCH             is supported   SQLFETCHSCROLL       is supported
SQLFOREIGNKEYS       is supported   SQLFREECONNECT       is supported
SQLFREEENV           is supported   SQLFREEHANDLE        is supported
SQLFREESTMT          is supported   SQLGETCONNECTATTR    is supported
SQLGETCONNECTOPTION  is supported   SQLGETCURSORNAME     is supported
SQLGETDATA           is supported   SQLGETDESCFIELD      is supported
SQLGETDESCREC        is supported   SQLGETDIAGFIELD      is supported
SQLGETDIAGREC        is supported   SQLGETENVATTR        is supported
SQLGETFUNCTIONS      is supported   SQLGETINFO           is supported
SQLGETLENGTH         is supported   SQLGETPOSITION       is supported
SQLGETSQLCA          is supported   SQLGETSTMTATTR       is supported
SQLGETSTMTOPTION     is supported   SQLGETSUBSTRING      is supported
SQLGETTYPEINFO       is supported   SQLMORERESULTS       is supported
SQLNATIVESQL         is supported   SQLNUMPARAMS         is supported
SQLNUMRESULTCOLS     is supported   SQLPARAMDATA         is supported
SQLPARAMOPTIONS      is supported   SQLPREPARE           is supported
SQLPRIMARYKEYS       is supported   SQLPROCEDURECOLUMNS  is supported
SQLPROCEDURES        is supported   SQLPUTDATA           is supported
SQLROWCOUNT          is supported   SQLSETCOLATTRIBUTES  is supported
SQLSETCONNECTATTR    is supported   SQLSETCONNECTION     is supported
SQLSETCONNECTOPTION  is supported   SQLSETCURSORNAME     is supported
SQLSETDESCFIELD      is supported   SQLSETDESCREC        is supported
SQLSETENVATTR        is supported   SQLSETPARAM          is supported
SQLSETPOS            is supported   SQLSETSCROLLOPTIONS  is supported
SQLSETSTMTATTR       is supported   SQLSETSTMTOPTION     is supported
SQLSPECIALCOLUMNS    is supported   SQLSTATISTICS        is supported
SQLTABLEPRIVILEGES   is supported   SQLTABLES            is supported
SQLTRANSACT          is supported
 

Note:The LOB support functions (SQLGetLength(), SQLGetPosition(), SQLGetSubString(), SQLBindFileToCol(), SQLBindFileToCol()) are not supported when connected to DB2 for common server prior to Version 2.1 or other IBM RDBMSs that do not support LOB data types.

Return Codes

Diagnostics

Table 110. SQLGetFunctions SQLSTATEs
SQLSTATE Description Explanation
40003 08S01 Communication link failure. The communication link between the application and data source failed before the function completed.
58004 Unexpected system failure. Unrecoverable system error.
HY001 Memory allocation failure. DB2 CLI is unable to allocate memory required to support execution or completion of the function.
HY010 Function sequence error. SQLGetFunctions() was called before a database connection was established.
HY013 Unexpected memory handling error. DB2 CLI was unable to access memory required to support execution or completion of the function.

Authorization

None.

CLI Sample ilinfo.c

The following example generates the listing shown in Figure 17 for any data source.

(The complete sample ilinfo.c is also available here .)

 
/* From the CLI sample ILINFO.C */
/* ... */
 
    /* check to see if SQLGetInfo() is supported */
    sqlrc = SQLGetFunctions(hdbc, SQL_API_SQLGETINFO, &supported);
    HANDLE_CHECK( SQL_HANDLE_DBC, hdbc, sqlrc, &henv, &hdbc ) ;     
    
 

References

None.


[ Top of Page | Previous Page | Next Page ]