I got the following query but encounter an exception.
This is the query we have
SELECT varchar_column_a FROM table_a, table_b
WHERE varchar_column_a LIKE
'% ' || CAST(CAST(int_column_b AS CHAR(10)) AS VARCHAR(10)) || ' %'
As the name stated, what I want to do is to cast an int column as
varchar and act as a string in the LIKE clause.
Follow is the exception throw
SQL0132N A LIKE predicate or POSSTR scalar function is not valid
because the first operand is not a string expression or the second
operand is not a string. SQLSTATE=42824
An expression that specifies the string that is to be matched.
The expression can be specified by any one of:
- a constant
- a special register
- a host variable
- a scalar function whose operands are any of the above
- an expression concatenating any of the above
So, it doesn't look like you can use "int_column_b" there.