Database connections / Unique session mode connection instructions |
Opens a new database connection in unique-session mode.
DATABASE { dbname[@dbserver] | variable | string } [EXCLUSIVE]
MAIN DATABASE stores ... END MAIN
MAIN DEFINE dbname VARCHAR(100) LET dbname = arg_val(1) DATABASE dbname ... END MAIN
If 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 could 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 should be avoided when writing a portable SQL application.
The CONNECT TO instructions allow better control over database connections; you should 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.