DATABASE
Opens a new database connection in unique-session mode.
Syntax
DATABASE { dbname[@dbserver] | variable | string } [EXCLUSIVE] - dbname identifies the database name.
- dbserver identifies the IBM® Informix® database server (INFORMIXSERVER).
- variable can be any character string defined variable containing the database specification.
- string can be a string literal containing the database specification.
Usage
DATABASE instruction
opens a connection to the database server, like CONNECT TO,
but without user and password specification.MAIN
DATABASE stores
...
END MAINMAIN
DEFINE dbname VARCHAR(100)
LET dbname = arg_val(1)
DATABASE dbname
...
END MAINIf a current connection exists, it is automatically closed before connecting to the new database.
The
connection is closed with the CLOSE DATABASE instruction,
or when the program ends.
The DATABASE instruction raises an exception if the connection can not be
established, for example, if you specify a database that the runtime system cannot
locate, or cannot open, or for which the user of your program does not have access
privileges.
The EXCLUSIVE keyword can be used to open an IBM
Informix database in exclusive mode to
prevent access by anyone but the current user. This keyword is IBM
Informix specific and is not recommended
when writing a portable SQL application.
The CONNECT TO instructions allow better control
over database connections; it is recommended that you use these instructions instead
of DATABASE and CLOSE DATABASE.
When used outside a program block, the DATABASE instruction
defines the database schema for compilation. See SCHEMA for more details.