DB_Tables Function

Action

Returns the list of table names, catalog names, or schema names, and the table types that are stored in a specific data source. The information is returned as a result set on the statement handle.

Syntax

hstmnt = DB_Tables (hdbc, catalog-name, schema-name, table-name, table-type)
Variable Description
hstmnt

The returned handle to the executed SQL statement. This is an input parameter for other DBTester functions, for example DB_FetchNext. HSQL.

hdbc

The handle to a database as returned by DB_Connect. HDATABASE.

catalog-name

Catalog name. STRING.

schema-name

String search pattern for schema names. STRING.

table-name

String search pattern for table names. STRING.

table-type
List of table types to match.
  • "TABLE"
  • "VIEW"
  • "TABLE,VIEW"
STRING.

Notes

  • DB_Tables corresponds to SQLTables. For additional information about SQLTables, see SQLTables Function.

  • The following wildcard characters are supported for arguments:
    Wildcard character Matches
    % The percent sign matches any character sequence.
    _ The underscore matches any single character.
  • To omit an argument variable, specify it as NULL.

  • When you receive a valid statement handle, you can call DB_FetchNext or DB_FetchPrevious to manipulate the information.

  • The wildcards do not work in a DB_Tables call against SQL Server. If you use these wildcards in such a call, Silk Test Classic returns no information.

Example

[-] testcase DBTablesExample () appstate none 
	[ ] // Retrieve all tables beginning with the letter 'p' (or 'P').
	[ ] // Assume that hdbc is a valid database handle returned from DB_Connect(). 
	[ ] STRING cat, sch, tbl, name, tbltype, ignore
	[ ] 
	[ ] cat = NULL 
	[ ] sch = NULL 
	[ ] tbl = "p%" 
	[ ] tbltype = NULL 
	[ ]   
	[ ] HDATABASE hdbc 
	[ ] HSQL hstmnt 
	[ ] 
	[ ] hdbc =DB_Connect("DSN=<DSNNAME>") 
	[ ] 
	[ ] // retrieve and print table name; ignore the rest.  
	[ ] hstmnt = DB_Tables (hdbc, cat, sch, tbl, tbltype) 
	[-] while (DB_FetchNext (hstmnt,ignore,ignore,name,ignore) == TRUE) 
		[ ] print (name) 
	[ ]   
	[ ] DB_Disconnect (hdbc)