Passing sql as parameter

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
wahi80
Participant
Posts: 214
Joined: Thu Feb 07, 2008 4:37 pm

Passing sql as parameter

Post by wahi80 »

Hi,

Im passing an Sql query as a parameter to the job
e.g select name where state in ('NY','NJ')
The query works fine in Oracle but when I pass it as a parameter to the job, it fails. On going through the log I saw that the query was not getting coverted properly.
The log was as follows :
Oracle_Enterprise_0: The provided query statement did not prepare correctly;
please verify that your statement is correct;
statement: SELECT name where state in (NY,NJ).

The quotes were removed from the in clause,hence the failure.

Can anyone point me to what should be done so that Datastage interprets the quotes.

The job runs fine if I pass a query with numeric data e.g: select name where empid=189

Regards
Wah
BugFree
Participant
Posts: 82
Joined: Wed Dec 13, 2006 6:02 am

Post by BugFree »

Try with an escape character.

Code: Select all

select name where state in (\'NY\',\'NJ\')
Ping me if I am wrong...
Kirtikumar
Participant
Posts: 437
Joined: Fri Oct 15, 2004 6:13 am
Location: Pune, India

Post by Kirtikumar »

Rather than going for IN clause and a parameterized approach there might be a simple approach to deal with this.

Is you table going to be constant in the SELECT stmt? If yes, you can go for something else in this case.
Regards,
S. Kirtikumar.
wahi80
Participant
Posts: 214
Joined: Thu Feb 07, 2008 4:37 pm

Post by wahi80 »

[quote="BugFree"]Try with an escape character. [code]select name where state in (\'NY\',\'NJ\')[/code][/quote]

Hi,
I have tried the above query, but still an error is displayed:

[code]Oracle_Enterprise_0: The provided query statement did not prepare correctly;
please verify that your statement is correct;
statement: select name where state in(\NY\,\NJ\).[/code]

I think the above code works properly in 7.5, but fails in 8.0

As to the next question the table is going to be a constant but the where condition will keep changing.

Any other ideas??

Regards
Wah
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

wahi80 wrote:I think the above code works properly in 7.5, but fails in 8.0
If that's the case then you need to involve support. That would be a bug that they'd need to fix. (or may already have fixed)
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply