Page 1 of 1

WHERE condition as a parameter

Posted: Fri May 07, 2010 4:51 pm
by Terala
Hi,

I have a requirement to extract data from source tables - for that i am using ODBC EE start. requirement is to pass the where condition as a parameter . I am getting SQL0401N when i pass where condition using IN but when i hard code the same query using IN statement it works fine.

Any workaround to overcome this issues?

Thanks

Posted: Fri May 07, 2010 5:15 pm
by ray.wurlod
A Search of DSXchange will suggest that what you want to do is not easily possible, though it IS possible to pass the entire SQL statement as a parameter and to use that as user-defined SQL.

Posted: Fri May 07, 2010 5:26 pm
by Terala
Hi Ray,

I did not search before posting it but i could find only one posting with the same error message.

I tried to provide entire sql statement as a parameter by defining User defined SQL in ODBC section, i am still getting same error message.

Here is sample of sql
select * from table where col1 in ('a', 'b', 'c')

Thanks,

Posted: Fri May 07, 2010 7:18 pm
by chulett
The issue is always the same when people feel the need to do this - DataStage strips the quotes from the parameter. You need to 'escape' them to try to preserve them.

Posted: Sat May 08, 2010 7:28 am
by Terala
can you guide me how to 'escape' them?

Posted: Sat May 08, 2010 8:10 am
by chulett
A search would turn up all the various techniques people have tried, what does (and doesn't) work. First thing to try - a "backslash" before each one.

Posted: Mon May 10, 2010 10:42 pm
by Terala
It worked.. with below modification in SQL

select * from table where col1 in (\'a\', \'b\', \'c\')

Thanks,

Posted: Thu May 13, 2010 1:52 pm
by Terala
I ran in another issues.
In my where condition parameter i have <= and > conditions.
passing <= or >= is not taking and job throwing error message "
SQL0104N An unexpected token "'<='" was found"

how can i over come this? I tried escaping them but no luck.

Thanks,

Posted: Thu May 13, 2010 3:09 pm
by anbu
Add another job parameter COND

Code: Select all

(#COND# = 'LT' AND COL1 < COL2) OR
(#COND# = 'GT' AND COL1 > COL2) OR