Stores a list of column names and information about each column for the specified data source table to a Visual FoxPro cursor.
SQLCOLUMNS(nStatementHandle, cTableName [, "FOXPRO" | "NATIVE"] [, cCursorName]) |
Parameters
- nStatementHandle
- Specifies an active statement handle.
- cTableName
- Specifies the name of the table from which the column names are returned. TableName can contain the wildcard characters ? and *. The question mark (?) matches any single character and the asterisk (*) matches any number of characters.
- FOXPRO | NATIVE
-
Specifies the format for the column information in the result set. Be sure to enclose FOXPRO or NATIVE in quotation marks. The NATIVE format option stores column information for tables in the same format as the data source. The FOXPRO format option stores the column information in the same format as that used for the Visual FoxPro table or cursor that would be created if you imported the data source table into Visual FoxPro. If you omit FOXPRO or NATIVE, the format option defaults to FOXPRO.
The following table shows the columns in the result set for the FOXPRO format.
The columns in the result set for the NATIVE format depend on the data source. If the table you specify with cTableName does not exist and the format is set to NATIVE, SQLCOLUMNS(В ) returns true (.T.) and creates an empty table or cursor. If the table you specify with cTableName does not exist and the format is set to FOXPRO, SQLCOLUMNS(В ) returns false (.F.).Column name Description Field_name
Column name
Field_type
Column data type
Field_len
Column length
Field_dec
Number of decimal places
- cCursorName
- Specifies the name of the Visual FoxPro cursor for the result set. If you do not include a cursor name, Visual FoxPro uses the default name SQLRESULT.
Return Value
Numeric or Logical. SQLCOLUMNS( ) returns 1 if the cursor is successfully created, 0 if SQLCOLUMNS( ) is still executing, – 1 if a connection level error occurs, and – 2 if an environment level error occurs.
Remarks
SQLCOLUMNS(В ) is one of the four functions that you can execute either synchronously or asynchronously. The Asynchronous setting of SQLSETPROP(В ) determines if these functions execute synchronously or asynchronously. In asynchronous mode, you must call SQLCOLUMNS(В ) repeatedly until a value other than false (.F.) (still executing) is returned.
Example
The following example assumes SQLCONNECT(В ) is successfully issued, and its return value is stored to a memory variable named gnHandle
. SQLCOLUMNS(В ) is used to create a cursor named MyCursor
containing information about the columns in the authors
table.
В | Copy Code |
---|---|
= SQLCOLUMNS(gnHandle, 'authors', 'FOXPRO', 'MyCursor') |