ODBC Get Schema Method

The ODBC Get Schema method is a Siebel VB method that returns the following information:

  • Data sources available

  • Current user ID

  • Names of tables names

  • Types of table columns

  • Other data source and database information

Format

SQLGetSchema connection, action, qualifier, ref()

The following table describes the arguments that you can use with this method.

Argument Description

connection

A long integer that the ODBC Open method returns.

action

An integer that specifies what information to return. Some database products and some ODBC drivers might not support every action.

qualifier

A string.

ref

An array of type variant that stores the results. It must be an array even if it includes only one dimension with one element.

You must make sure the destination array is properly dimensioned to support the action. If you do not do this, then this method returns an error.

Values You Can Use In the Action Argument

ODBC Get Schema Method describes the values you can use in the action argument. If the ODBC Get Schema method cannot find the requested information or if the connection is not valid, then it returns a -1 (negative one).

Value Description

1

Get a list of available data sources. The dimension of ref() is 1.

2

Get a list of databases on the current connection. Siebel VB does not support this value.

3

Get a list of owners in a database on the current connection. Siebel VB does not support this value.

4

Get a list of tables on the specified connection. It returns every table. You cannot use the qualifier argument with value 4.

5

Get a list of columns in the table that the qualifier argument and the ref argument specifies. This table must include two dimensions. This method returns the column name and the ODBC data type.

6

Get the user ID of the current connection user.

7

Get the name of the current database.

8

Get the name of the data source of the current connection.

9

Get the name of the RDBMS that the data source uses. For example, DB2.

10

Get the server name of the data source.

11

Get the terminology that the data source uses to reference owners.

12

Get the terminology that the data source uses to reference a table.

13

Get the terminology that the data source uses to reference a qualifier.

14

Get the terminology that the data source uses to reference a procedure.

Example

The following example opens the data source named SblTest, gets the names in the ODBC data sources, and then 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