Informix Error -358
-358 Must close current database before CREATE, START or ROLLFORWARD.
These statements choose a new current database, but the present database must be closed first. Use the CLOSE DATABASE statement before this statement.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-358 fires when CREATE DATABASE, START DATABASE, or ROLLFORWARD DATABASE is attempted while
a database is still open in the current session — each of these statements is going to select a
new current database, and the server requires the existing one to be explicitly closed first
rather than switching implicitly.
- A session with an already-open database attempting
CREATE DATABASE/START DATABASE/ROLLFORWARD DATABASEwithout an interveningCLOSE DATABASE— the direct, only cause. - A script assuming these statements behave like
DATABASE(which does switch the current database directly) rather than requiring an explicit close first. - Session/connection reuse logic that doesn't track whether a database is currently open before attempting one of these statements.
Solutions / Resolution
- Issue
CLOSE DATABASEbeforeCREATE,START, orROLLFORWARD, per the official guidance — this is a required step, not optional cleanup. - For reusable session/connection logic, track whether a database is currently open and close it proactively before attempting one of these statements.
Examples
Closing the current database first
DATABASE sales;
-- ... work in sales ...
CLOSE DATABASE;
CREATE DATABASE sales_archive;
The disallowed direct attempt
DATABASE sales;
CREATE DATABASE sales_archive;
-- -358: sales is still open; CLOSE DATABASE is required first
Diagnostic Checks
- Check whether a database is currently open in the session before attempting
CREATE,START, orROLLFORWARD DATABASE. - Confirm
CLOSE DATABASEis issued immediately beforehand, with no other database-opening statement in between.
Related Errors / Related Topics
- -349 — "Database not selected yet." The mirror-image condition — this error fires when no
database is open and one is needed;
-358fires when one is already open and needs to be explicitly closed first.
CREATE, START, and ROLLFORWARD DATABASE all require an explicit CLOSE DATABASE first —
unlike plain DATABASE, they won't implicitly switch away from an already-open database.