Concatenate variable with LIKE clause

Stimulsoft Reports.WEB discussion
Post Reply
gabrielw3n
Posts: 14
Joined: Mon Aug 21, 2017 5:10 pm

Concatenate variable with LIKE clause

Post by gabrielw3n »

Hello.

Please, I would like to concatenate an "AND" clause based on a variable value but I'm getting errors because of the 'LIKE' and '%%'.

This is what I'm doing:

Code: Select all

{occurrenceType == "M" ? " AND occurrence.fk_doc = " + doctor + "" : " AND patient.nameLIKE '%'" + {patient_name} + "%'"}
Please, I'm geting SQL errors.

What is the correct way to escape a single quotation mark or use a clause WHERE using a variable?
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Re: Concatenate variable with LIKE clause

Post by Edward »

Hi Gabriel,

I have noticed that you have got nested curly brackets in that expression, that is not supported, please try to modify your expression like follows:

Code: Select all

{ occurrenceType == "M" ? " AND occurrence.fk_doc = " + doctor + "" : " AND patient.name LIKE '%'" + patient_name + "%'"}
Thank you,
Edward
Post Reply