SQLTABLES( ) Function

Example   See Also

Stores the names of tables in a data source to a Visual FoxPro cursor.

Syntax

SQLTABLES(nConnectionHandle [, cTableTypes] [, cCursorName])

Returns

Numeric

Arguments

nConnectionHandle

Specifies the connection handle to the data source returned by SQLCONNECT( ).

cTableTypes

Specifies one or more table types. Valid table types are 'TABLE,' 'VIEW,' 'SYSTEM TABLE,' or any valid data source-specific table type identifier. cTabletypes must be in upper-case. If you include a list of table types, separate the table types with commas.

All table names in the data source are selected if you omit cTableTypes or if cTableTypes is the empty string.

The table type you specify must be delimited with single quotation marks. The following example demonstrates how to specify the 'VIEW' and 'SYSTEM TABLE' table types as a string literal.

? SQLTABLES(handle, "'VIEW', 'SYSTEM TABLE'", "mydbresult")

cCursorName

Specifies the name of the Visual FoxPro cursor to which the result set is sent. If you don't include a cursor name, Visual FoxPro uses the default name SQLRESULT.

The following table shows the columns in the cursor.

Column name Description
TABLE_QUALIFIER Table qualifier identifier
TABLE_OWNER Table owner identifier
TABLE_NAME The table name as it appears in the data dictionary
TABLE_TYPE The table type as it appears in the data dictionary
REMARKS A description of the table

Remarks

SQLTABLES( ) returns 1 if the cursor is successfully created, 0 if SQLTABLES( ) is still executing,  – 1 if a connection level error occurs, and  – 2 if an environment level error occurs.

SQLTABLES( ) is one of the four functions that you can execute either synchronously or asynchronously. The setting of the SQLSETPROP( ) asynchronous option determines if these functions execute synchronously or asynchronously. In asynchronous mode, you must call SQLTABLES( ) repeatedly until it returns a value other than false (.F.), meaning the function is still executing.