Siebel VB Language Reference > VB Language Reference >

SQLGetSchema Function

This custom VB function returns a variety of information, including information on the data sources available, current user ID, names of tables, names and types of table columns, and other data source/database related information.

NOTE:  Siebel VB SQLxxxx functions are supported for non-Unicode databases only.


SQLGetSchema connection, action, qualifier, ref()



A long integer returned by SQLOpen


An integer value from the following table, specifying what is to be returned to ref()


A string


An array of type variant for the results appropriate to the action requested; it must be an array even if it has only one dimension with one element


A variant whose value depends on the action requested, as determined by the values in Table 6. A negative return value indicates an error. A -1 is returned if the requested information cannot be found or if the connection is not valid.

Table 6.  Values for Action
Action Value


List of available data sources (dimension of ref() is 1)


List of databases on the current connection (not supported)


List of owners in a database on the current connection (not supported)


List of tables on the specified connection


List of columns in the table specified by qualifier (ref() must be two dimensions); returns the column name and SQL data type


The user ID of the current connection user


The name of the current database


The name of the data source for the current connection


The name of the DBMS the data source uses (for example, DB2)


The server name for the data source


The terminology used by the data source to refer to owners


The terminology used by the data source to refer to a table


The terminology used by the data source to refer to a qualifier


The terminology used by the data source to refer to a procedure


The destination array must be properly dimensioned to support the action, or an error is returned. Actions 2 and 3 are not currently supported. Action 4 returns every table and does not support the use of the qualifier. Not every database product and ODBC driver support every action.

CAUTION:  This function, as well as the other SQL functions available in Siebel VB, should not be used to query the underlying database. Use the Siebel Object Interfaces to query Siebel data. Use the SQL functions only to query non-Siebel data.


This example opens the data source named SblTest, gets the names in the ODBC data sources, and closes the connection.

Sub Button_Click
       Dim outputStr As String
       Dim connection As Long
       Dim prompt As Integer
       Dim datasources(1 To 50) As Variant
       Dim retcode As Variant
       prompt = 5
      'Open the data source "SblTest"
       connection = SQLOpen("DSN=SblTest; UID=SADMIN; PWD=SADMIN", outputStr,prompt:=4)
       action1 = 1 ' Get the names of the ODBC data sources
       retcode = SQLGetSchema(connection:= connection,action:= 1,qualifier:= qualifier, ref:= datasources())

      'Close the data source connection
       retcode = SQLClose(connection)
      End Sub

See Also

SQLClose Function
SQLError Function
SQLExecQuery Function
SQLOpen Function
SQLRequest Function
SQLRetrieve Function
SQLRetrieveToFile Function

Siebel VB Language Reference