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.
Syntax
SQLGetSchema connection, action, qualifier, ref()
|
|
connection |
A long integer returned by SQLOpen |
action |
An integer value from the following table, specifying what is to be returned to ref() |
qualifier |
A string |
ref() |
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 |
Returns
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
|
|
1 |
List of available data sources (dimension of ref() is 1) |
2 |
List of databases on the current connection (not supported) |
3 |
List of owners in a database on the current connection (not supported) |
4 |
List of tables on the specified connection |
5 |
List of columns in the table specified by qualifier (ref() must be two dimensions); returns the column name and SQL data type |
6 |
The user ID of the current connection user |
7 |
The name of the current database |
8 |
The name of the data source for the current connection |
9 |
The name of the DBMS the data source uses (for example, DB2) |
10 |
The server name for the data source |
11 |
The terminology used by the data source to refer to owners |
12 |
The terminology used by the data source to refer to a table |
13 |
The terminology used by the data source to refer to a qualifier |
14 |
The terminology used by the data source to refer to a procedure |
Usage
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.
Example
This example opens the data source named SblTest, gets the names in the ODBC data sources, and closes the connection. Sub Button_Click 'Declarations 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
|