Informix Error -26059: Unsupported data type in EXECUTE IMMEDIATE or PREPARE statement
Cause and resolution
Unsupported data type in EXECUTE IMMEDIATE or PREPARE statement
A variable passed to the EXECUTE IMMEDIATE statement or PREPARE statement in SPL must be one of the data types CHAR, VARCHAR, LVARCHAR, NCHAR, or NVARCHAR. Change your program logic to pass a variable of one of these supported data types to the EXECUTE IMMEDIATE statement or PREPARE statement in the SPL routine.
In an SPL routine, the following examples are not valid because the EXECUTE IMMEDIATE or PREPARE statement does not support variables of type TEXT:
Case (1) DEFINE qstr REFERENCES TEXT; ... LET qstr = (SELECT textcol FROM t1 WHERE qryid = 100); EXECUTE IMMEDIATE qstr;
Case (2) DEFINE qstr REFERENCES TEXT; ... LET qstr = (SELECT textcol FROM t1 WHERE qryid = 100); PREPARE stmt_id FROM qstr;
The following examples include a valid EXECUTE IMMEDIATE statement and a PREPARE statement in SPL routine:
Case (3) DEFINE qstr varchar(120); ... LET qstr = "create table t1 (c1 int);"; EXECUTE IMMEDIATE qstr;
Case (4) DEFINE qstr lvarchar; ... LET qstr = "select lvarcol from t1 where qryid = 100"; PREPARE stmt_id FROM qstr;
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-26059 fires when a variable passed to SPL's EXECUTE IMMEDIATE/PREPARE isn't one of the
supported string types — per the official guidance.
- The variable's data type isn't
CHAR,VARCHAR,LVARCHAR,NCHAR, orNVARCHAR, per the official guidance — the direct, only cause (e.g.TEXTisn't supported).
Solutions / Resolution
- Change the variable's data type to
CHAR,VARCHAR,LVARCHAR,NCHAR, orNVARCHAR, per the official guidance.
Examples
Invalid: a TEXT variable
DEFINE qstr REFERENCES TEXT;
LET qstr = (SELECT textcol FROM t1 WHERE qryid = 100);
EXECUTE IMMEDIATE qstr;
-- -26059: TEXT is not a supported type
Corrected
DEFINE qstr VARCHAR(120);
LET qstr = "create table t1 (c1 int);";
EXECUTE IMMEDIATE qstr;
Diagnostic Checks
- Check the data type of the variable passed to
EXECUTE IMMEDIATE/PREPARE, and confirm it's one of the supported string types.
Related Errors / Related Topics
- -26051 — "EXECUTE IMMEDIATE and PREPARE cannot take NULL statement" A related
EXECUTE IMMEDIATE/PREPARErestriction, on a null value rather than an unsupported data type. - -26058 — "EXECUTE IMMEDIATE and PREPARE in SPL cannot allow multiple SQL statements."
A related
EXECUTE IMMEDIATE/PREPARErestriction, on multiple statements rather than an unsupported data type.
A variable of an unsupported data type (e.g. TEXT) was passed to EXECUTE IMMEDIATE/
PREPARE — use CHAR/VARCHAR/LVARCHAR/NCHAR/NVARCHAR instead.