Additional CONNECT Syntax

From InterBase
Jump to: navigation, search

Go Up to Opening a Database


CONNECT supports several formats for opening databases to provide programming flexibility. The following table outlines each possible syntax, provides descriptions and examples, and indicates whether CONNECT can be used in programs that access single or multiple databases:

CONNECT syntax summary
Syntax Description Single
access
Multiple
access

CONNECT ‘<dbfile’>;

Opens a single, hard-coded database file, <dbfile>.

Example:

EXEC SQL
CONNECT ‘employee.ib’;

Yes

No

CONNECT <handle>;

Opens the database file associated with a previously declared database handle. This is the preferred CONNECT syntax.

Example:

EXEC SQL
CONNECT EMP;

Yes

Yes

CONNECT ‘<dbfile>’ AS <handle>;

Opens a hard-coded database file, <dbfile>, and assigns a previously declared database handle to it.

Example:

EXEC SQL
CONNECT ‘employee.ib’ AS EMP;

Yes

Yes

CONNECT<br/>:<varname> AS <handle>;

Opens the database file stored in the host-language variable, <varname>, and assigns a previously declared database handle to it.

Example:

EXEC SQL
CONNECT :fname AS EMP;

Yes

Yes

For a complete discussion of CONNECT syntax and its uses, see the Language Reference Guide.

Advance To: