Description:
|
DB2Dialect uses AnsiTrimEmulationFunction for the "trim" function. This attempts to use the following SQL:
select replace(replace(ltrim(rtrim(replace(replace(customer0_.NAME, ' ', '${space}$'), ?, ' '))), ' ', ?), '${space}$', ' ')
This fails w/ the following error:
com.ibm.db2.jcc.am.
SqlSyntaxErrorException
SqlException
: DB2 SQL Error: SQLCODE=-
418
313
, SQLSTATE=
42610
, SQLERRMC=null, DRIVER=4.13.80
Allowing the dialect to use the
When
"trim
(?1 ?2 ?3 ?4)
"
instead results in:
select
is bound, it expects the
trim
(BOTH ? from customer0_
character to appear only once in the statement
.
NAME) as col_0_0_ from CUSTOMER_TABLE customer0_ where customer0_.NAME=?
com.ibm.db2.jcc.am.SqlSyntaxErrorException: DB2
In AnsiTrimEmulationFunction's
SQL
Error: SQLCODE=-123
,
SQLSTATE=42601, SQLERRMC=strip-or-
? occurs twice. The
trim
-
char
;SYSIBM.TRIM, DRIVER=4.13.80
Neither method is attempting
needs
to
use a literal.
The 418 error code page states that:
{quote} The statement cannot
be
executed because a parameter marker has been used in an invalid way
bound more than once
.
Parameter markers
DB2's trim()
cannot be used
:
In the SELECT list as the sole argument of a scalar function. In a concatenation operation. In the string expression of an EXECUTE IMMEDIATE SQL statement. In a result
-
expression in any CASE expression when all the other result
-
expressions are either NULL or untyped parameter markers. In a key-expression of an index definition.
Untyped parameter markers cannot be used:
As an argument
it refuses
to
an XMLQUERY function. As an argument to an XMLEXISTS predicate. {quote}
Unless I'm missing something
allow parameter values as arguments
,
the queries appear to be meeting the rules
even if they're cast
.
See CriteriaCompilingTest#testTrim for a test case.
|