DB_ForeignKeys Function


Returns either a list of foreign keys, which are columns in the specified table that refer to primary keys in other tables, or a list of foreign keys in other tables that refer to the primary key in the specified table. The list is returned as a result set on the statement handle.


hstmnt = DB_ForeignKeys (hdbc, pcatalog-name, pschema-name, ptable-name, fcatalog-name, fschema-name, ftable-name)
Variable Description

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


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


Primary key table catalog name. STRING.


Primary key table schema name. STRING.


Primary key table name. STRING.


Foreign key catalog name. STRING.


Foreign key schema name. STRING.


Foreign key table name. STRING.


  • DB_ForeignKeys corresponds to SQLForeignKeys. For additional information about SQLForeignKeys, see SQLForeignKeys Function.

  • The arguments ptable-name and ftable-name cannot contain wildcards.
  • 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 a variable argument, which is not a required argument, specify the argument as an empty string ("").

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


[ ] STRING pcat, psch, ptable, fcat, fsch, ftable, ignore, fkcol, key-seq 
[ ] hstmnt = DB_ForeignKeys (hdbc, pcat, psch, ptable, fcat, fsch, ftable)
[ ] // retrieve foreign key column and key sequence; ignore the rest.
[-] while (DB_FetchNext (hstmt, ignore, ignore, ignore, ignore, ignore, ignore, ignore, fkcol, key-seq) == TRUE) { 
	[ ] //print FK columns and key sequence ...
[-] }