Using a Hard-coded Database Names
Go Up to Using simple CONNECT Statements
In Single-database Programs
In a single-database program that omits
CONNECT must contain a hard-coded, quoted file name in the following format:
EXEC SQL CONNECT '[host[path]]filename';
<host> is required only if a program and a database file it uses reside on different nodes. Similarly, <path> is required only if the database file does not reside in the current working directory. For example, the following
CONNECT statement contains a hard-coded file name that includes both a Unix host name and a path name:
EXEC SQL CONNECT 'valdez:usr/interbase/examples/employee.ib';
- Note: Host syntax is specific to each server platform.
- Important: A program that accesses multiple databases cannot use this form of
in Multi-database Programs
A program that accesses multiple databases must declare handles for each of them in separate
SET DATABASE statements. These handles must be used in subsequent
CONNECT statements to identify specific databases to open:
. . . EXEC SQL SET DATABASE DB1 = 'employee.ib'; EXEC SQL SET DATABASE DB2 = 'employee2.ib'; EXEC SQL CONNECT DB1; EXEC SQL CONNECT DB2; . . .
Later, when the program closes these databases, the database handles are no longer in use. These handles can be reassigned to other databases by hard-coding a file name in a subsequent
CONNECT statement. For example,
. . . EXEC SQL DISCONNECT DB1, DB2; EXEC SQL CONNECT 'project.ib' AS DB1; . . .