dbListTables

Top  Previous  Next

Syntax

POINTER = dbListTables(pConnection as POINTER)

Description

Returns a linked list containing the names of all of the tables in a database.

Parameters

pConneciton - A database pointer returned by dbConnect or dbConnectDSN

Return value

A pointer to a linked list of table names or NULL if the database 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 table names.  Each element of the list is a pointer to a string containing a table name.

Example usage

REM List all tables, and their columns
pTables = dbListTables(pdb)
PRINT "Tables:"
IF pTables <> NULL
    FOR temp = EACH pTables as STRING
        PRINT #temp
        PRINT "\tColumns:"
        pColumns = dbListColumns(pdb,#temp)
        IF pColumns <> NULL
            FOR temp2 = EACH pColumns as STRING
                PRINT "\t\t",#temp2
            NEXT
            ListRemoveAll(pColumns,TRUE)
        ENDIF
    NEXT
    ListRemoveAll(pTables,TRUE)
ELSE
    PRINT "Unable to list tables"
ENDIF