![]() |
|
Use the CLOSE DATABASE statement to close the current database.
When you issue a CLOSE DATABASE statement, you can issue only the following SQL statements immediately after it:
Issue the CLOSE DATABASE statement before you drop the current database.
If your database has transactions, and if you have started a transaction, you must issue a COMMIT WORK statement before you use the CLOSE DATABASE statement.
The following example shows how to use the CLOSE DATABASE statement to drop the current database:
In ESQL/C, the CLOSE DATABASE statement cannot appear in a multistatement PREPARE operation.
If you use the CLOSE DATABASE statement within a UDR called by a WHENEVER statement, specify WHENEVER SQLERROR CONTINUE and WHENEVER SQLWARNING CONTINUE before the ROLLBACK WORK statement. This action prevents the program from looping if the ROLLBACK WORK statement encounters an error or a warning.
When you issue the CLOSE DATABASE statement, declared cursors are no longer valid. You must re-declare any cursors that you want to use.
Related statements: CONNECT, CREATE DATABASE, DATABASE, DISCONNECT, and DROP DATABASE