Using Strings or host-language Variables

From InterBase
Jump to: navigation, search

Go Up to Using simple CONNECT Statements


Instead of using a database handle, CONNECT can use a database name supplied at run time. The database name can be supplied as either a host-language variable or a hard-coded, quoted string.

The following C code demonstrates how a program accessing only a single database might implement CONNECT using a file name solicited from a user at run time:

. . .
char fname[125];
. . .
printf('Enter the desired database name, including node
and path):\n');
gets(fname);
. . .
EXEC SQL
CONNECT :fname;
. . .
Tip: This technique is especially useful for programs that are designed to work with many identically structured databases, one at a time, such as CAD/CAM or architectural databases.

Topics