I'm trying to build a dynamic LIKE statement, where the last 2 digits of the current year is passed into the LIKE part.
SELECT
COUNT(*) AS amount
FROM "ALLE" AS v
WHERE
(v.VMT != '' AND
v.VMT LIKE CONCAT(CONCAT('ID_', RIGHT(YEAR(NOW()),2)), '%') OR
v.VMT LIKE CONCAT('%', CONCAT('ID_', RIGHT(YEAR(NOW()),2)) )
CONCAT() in PSQL allows only 2 params.
I tried different things like:
CAST() the CONCAT with char
Put parenthesis around the CONCAT
Use WITH statement, what's not supported by PSQL so I tried a CROSS JOIN to feed in the strings from a plain select statement
Using the CONCAT/RIGHT function etc. in a stored procedure doesn't look like going to work either
Link to the docs: https://docs.actian.com/psql/psqlv13/index.html#page/sqlref%2Fsqlref.LIKE.htm%23
I guess this problem only applies to PervasiveSQL.
Somehow I need to pre-define both strings to feed them later into the LIKE part. But how?
I don't think Pervasive / Actian supports the
CONCATin aLIKEclause. I tried a very simple statement:and I got a Syntax Error with the error indicating a problem between the CONCAT and the parenthesis. Something like:
Using the
CONCATin aWHEREClause with an = worked. Something likeI would suggest contacting Actian and opening a defect with them.