Informix Error -555: Cannot use a select or any of the database statements in a multi-query prepare.
Cause and resolution
Cannot use a select or any of the database statements in a multi-query prepare.
The statement text that is presented with this PREPARE statement has multiple statements divided by semicolons, and one is a SELECT, DATABASE, CREATE DATABASE, or CLOSE DATABASE statement. These statements must always be prepared as one-statement texts. Check the statement text string, and make sure that you intended multiple statements. If you did, revise the program to execute these four statement types alone.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-555 fires when a PREPARE statement's text contains multiple statements separated by
semicolons, and one of them is a SELECT, DATABASE, CREATE DATABASE, or CLOSE DATABASE
statement — per the official guidance, these four statement types must always be prepared alone,
never as part of a multi-statement batch.
- A
SELECTincluded in a semicolon-separated multi-statement prepare — per the official guidance, one of the four disallowed types in that context. - A
DATABASE/CREATE DATABASE/CLOSE DATABASEstatement bundled with others in the same prepared text, for the same reason. - Generic batch-preparation code that doesn't special-case these four statement types when assembling a multi-statement text.
Solutions / Resolution
- Check the statement text string, and confirm whether multiple statements were actually
intended, per the official guidance — sometimes an accidental semicolon merges what should
have been separate
PREPAREcalls. - If multiple statements are genuinely intended, execute the SELECT/DATABASE/CREATE DATABASE/ CLOSE DATABASE statement on its own, per the official guidance, separate from any other statements in the batch.
Examples
The disallowed batch
EXEC SQL PREPARE multi_stmt FROM
"SELECT * FROM orders WHERE order_id = ?; \
UPDATE orders SET status = 'reviewed' WHERE order_id = ?";
-- -555: SELECT cannot be part of a multi-statement prepare
Split apart
EXEC SQL PREPARE select_stmt FROM "SELECT * FROM orders WHERE order_id = ?";
EXEC SQL PREPARE update_stmt FROM "UPDATE orders SET status = 'reviewed' WHERE order_id = ?";
Diagnostic Checks
- Scan the prepared text for semicolons, and check whether any of the resulting individual
statements is a
SELECT,DATABASE,CREATE DATABASE, orCLOSE DATABASE— any of the four needs to be pulled out into its own prepare.
Related Errors / Related Topics
No closely related error codes are cross-referenced for -555 in this set yet.
Four specific statement types (SELECT, DATABASE, CREATE DATABASE, CLOSE DATABASE) can never be part of a multi-statement prepare — split them out into their own PREPARE.