Prepared Statements: CASE with parameter in WITH clause returns internal server error
Details
| Detail name | Value |
|---|---|
| Changelog Number | 15025 |
| Type | Bug |
| Status | Resolved |
| Affected Versions | Exasol 7.1.0, Exasol 8.0.0 |
| Fix Versions | Exasol 8.0.6, Exasol 7.1.12 |
| Resolution Date | 2022-07-13 |
Description
In the following scenario, a query may return an internal server error:
- Query is used in a prepared statement
- The query contains a WITH clause
- A CASE expression is used within the WITH clause
- The THEN clause in the CASE expression contains a parameter
Example:
WITH TEST AS ( SELECT CASE WHEN 1 IS NOT NULL THEN ? ELSE 'a' END AS t1 ) SELECT * FROM TEST;
Workaround
Cast the parameterized value to the proper data type. For example
WITH TEST AS ( SELECT CASE WHEN 1 IS NOT NULL THEN cast(? as VARCHAR(2000)) ELSE 'a' END AS t1 ) SELECT * FROM TEST;
Fix
The query succeeds as expected.