Using Handles for Table Names
Go Up to Declaring Multiple Databases
When the same table name occurs in more than one simultaneously accessed database, a database handle must be used to differentiate one table name from another. The database handle is used as a prefix to table names, and takes the form handle.table.
For example, in the following code, the database handles, TEST
and EMP
, are used to distinguish between two tables, each named EMPLOYEE
:
. . . EXEC SQL DECLARE IDMATCH CURSOR FOR SELECT TESTNO INTO :matchid FROM TEST.EMPLOYEE WHERE TESTNO > 100; EXEC SQL DECLARE EIDMATCH CURSOR FOR SELECT EMPNO INTO :empid FROM EMP.EMPLOYEE WHERE EMPNO = :matchid; . . .
- Important: This use of database handles applies only to embedded SQL applications. DSQL applications cannot access multiple databases simultaneously.