Using the RUNTIME Clause
Go Up to Preprocessing and Run Time Databases
When a database file is specified for use during preprocessing, SET DATABASE can specify a different database to use at run time by including the RUNTIME keyword and a runtime file specification:
EXEC SQL SET DATABASE EMP = COMPILETIME 'employee.ib' RUNTIME 'employee2.ib';
The file specification that follows the RUNTIME keyword can be either a hard-coded, quoted string, or a host-language variable. For example, the following C code fragment prompts the user for a database name, and stores the name in a variable that is used later in SET DATABASE:
. . .
char db_name[125];
. . .
printf("Enter the desired database name, including node
and path):\n");
gets(db_name);
EXEC SQL
SET DATABASE EMP = COMPILETIME 'employee.ib' RUNTIME :db_name;
. . .
- Note: Host-language variables in
SET DATABASEmust be preceded, as always, by a colon.