SQLCOLUMNS( ) Function

Stores a list of column names and information about each column for the specified data source table to a Visual FoxPro cursor.

SQLCOLUMNS(nConnectionHandle, cTableName
    [, "FOXPRO" | "NATIVE"] [, cCursorName])

Return Values

Numeric

Parameters

  • nConnectionHandle
    Active connection 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.

    Column name Description
    Field_name Column name
    Field_type Column data type
    Field_len Column length
    Field_dec Number of decimal places

    The following table shows the columns in the result set for the NATIVE format. In NATIVE format, depending on the data source, additional columns not listed in the following table may be included in the result set.

    Column name Description
    Table_qualifier Table qualifier identifier
    Table_owner Table owner identifier
    Table_name Table identifier
    Column_name Column identifier
    Data_type Column data type
    Type_name Column data type name
    Precision Precision of the column
    Length Transfer size of the data
    Scale Scale of the column
    Radix Base for Numeric type
    Nullable Supports null values
    Remarks Description of the column

    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.).

  • 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.

Remarks

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.

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 gnConnHandle. SQLCOLUMNS( ) is used to create a cursor named MyCursor containing information about the columns in the authors table.

= SQLCOLUMNS(gnConnHandle, 'authors', 'FOXPRO', 'MyCursor')

See Also

AERROR( ) | SQLGETPROP( ) | SQLSETPROP( ) | SQLTABLES( )