dbListColumns

Top  Previous  Next

Syntax

POINTER = dbListColumns(pConnection as POINTER,tableName as STRING,OPT hStmt as INT )

Description

Returns a linked list containing the names of all of the columns in a table or result set.

Parameters

pConnection - Database pointer returned by dbConnect or dbConnectDSN.

tableName - Name of the table to retrieve the column names

hstmt - Optional. A statement handle returned by dbExecSQL or dbPrepareSQL.

Return value

A pointer to a linked list of column names or NULL if the table or result set is empty.

Remarks

The pointer returned is a standard Emergence BASIC linked list type.  It must be deleted with ListRemoveAll when you are finished enumerating the column names.  Each element of the list is a pointer to a string containing a column name.

This command has two forums. For listing all of the column names in a particular table 'hstmt' must be omitted, or NULL.  For listing all of the column names in a result set 'tableName' must be an empty string "" and 'hstmt' must be a valid statement handle.  In either case the database pointer must be supplied.

Example usage

pColumns = dbListColumns(pdb,"",hstmt)
IF pColumns <> NULL
    FOR temp2 = EACH pColumns as STRING
        PRINT #temp2,", ",
    NEXT
    PRINT
    ListRemoveAll(pColumns,TRUE)
ENDIF
 
pColumns = dbListColumns(pdb,"USERS")
IF pColumns <> NULL
    FOR temp2 = EACH pColumns as STRING
        PRINT #temp2,", ",
    NEXT
    PRINT
    ListRemoveAll(pColumns,TRUE)
ENDIF