Informix Error -26058: EXECUTE IMMEDIATE and PREPARE in SPL cannot allow multiple SQL statements
Cause and resolution
EXECUTE IMMEDIATE and PREPARE in SPL cannot allow multiple SQL statements
Either EXECUTE IMMEDIATE or PREPARE statement in an SPL routine is trying to process an expression that evaluates to the text of more than one SQL statement. Change your program logic to pass to the EXECUTE IMMEDIATE or PREPARE statement an expression or a quoted string that evaluates to the text of only a single SQL statement.
In an SPL routine, the following examples are not valid because the EXECUTE IMMEDIATE or PREPARE statement specifies the text of more than one SQL statement:
Case (1) ... EXECUTE IMMEDIATE "create table t1(c1 int); create table t2(c2 int);" ; Case (2) ... LET qry = "select c1,c2 from t1; select c1,c2 from t2"; PREPARE stmt_id FROM qry;
These examples of EXECUTE IMMEDIATE and PREPARE statements are valid in an SPL routine:
Case (3) ... EXECUTE IMMEDIATE "create table t1(c1 int);" ; EXECUTE IMMEDIATE "create table t2(c2 int);" ;
Case (4) ... LET qry1 = "select c1,c2 from t1 ;"; PREPARE stmt_id1 FROM qry1;
LET qry2 = "select c1,c2 from t2 ;"; PREPARE stmt_id2 FROM qry2; Only ESQL/C routines can use the EXECUTE IMMEDIATE or PREPARE statement to process a semicolon-separated list of SQL statements.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-26058 fires when an SPL EXECUTE IMMEDIATE/PREPARE expression evaluates to more than
one SQL statement's text — per the official guidance.
- The expression evaluates to the text of more than one SQL statement, per the official guidance — the direct, only cause.
Solutions / Resolution
- Change the program logic so
EXECUTE IMMEDIATE/PREPAREis passed only a single SQL statement's text, per the official guidance.
Examples
Invalid: multiple statements in one call
EXECUTE IMMEDIATE "create table t1(c1 int); create table t2(c2 int);";
Corrected: one call per statement
EXECUTE IMMEDIATE "create table t1(c1 int);";
EXECUTE IMMEDIATE "create table t2(c2 int);";
Diagnostic Checks
- Check every
EXECUTE IMMEDIATE/PREPAREexpression in the SPL routine, and confirm each evaluates to exactly one SQL statement.
Related Errors / Related Topics
- -26051 — "EXECUTE IMMEDIATE and PREPARE cannot take NULL statement" A related
EXECUTE IMMEDIATE/PREPARErestriction, on a null expression rather than multiple statements. - -26059 — "Unsupported data type in EXECUTE IMMEDIATE or PREPARE statement." A related
EXECUTE IMMEDIATE/PREPARErestriction, on the variable's data type rather than multiple statements.
An SPL EXECUTE IMMEDIATE/PREPARE expression evaluated to more than one SQL statement —
split it into one call per statement.