PervasiveSQL CONCAT not working in LIKE statement

40 Views Asked by At

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:

  1. CAST() the CONCAT with char

  2. Put parenthesis around the CONCAT

  3. 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

  4. 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?

1

There are 1 best solutions below

0
mirtheil On

I don't think Pervasive / Actian supports the CONCAT in a LIKE clause. I tried a very simple statement:

SELECT * from T1 where C1 like concat('ID','test') 

and I got a Syntax Error with the error indicating a problem between the CONCAT and the parenthesis. Something like:

select * from T1 where C1 like concat<< ??? >>('ID','test')

Using the CONCAT in a WHERE Clause with an = worked. Something like

select * from T1 where C1 = concat('ID','test')

I would suggest contacting Actian and opening a defect with them.