Question
Alexander Grishkan · May 9, 2017

%CONTAINS parameters in embedded SQL

What is a correct way to pass parameters to the  %CONTAINS in embedded SQL statement when searching thru %Text property?

s sp="child,health"

&SQL(

DECLARE c1 CURSOR FOR

SELECT ID INTO :id FROM ICD WHERE Name %CONTAINS (:sp)

...

is not the same as executing the following in the SQL Manager

SELECT ID FROM ICD WHERE Name %CONTAINS ('child','health')

0
0 385
Discussion (4)4
Log in or sign up to continue

Alexander

I think you need to use 2 parameters in your COS code

s sp1="child"

s sp2="health"

&SQL(

DECLARE c1 CURSOR FOR

SELECT ID INTO :id FROM ICD WHERE Name %CONTAINS (:sp1, :sp2)

This would be equivalent to what you are doing in the Portal.

Brendan

Thank you Brendan.

If this is the only way, then I will have to do a dynamic SQL instead of the embedded one because the number of search words changes from one query to the next.

Thank you Brendan.

If this is the only way, then I will have to do a dynamic SQL instead of the embedded one because the number of search words changes from one query to the next.