Issue with DS Server Routine

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
das_nirmalya
Participant
Posts: 59
Joined: Thu Mar 20, 2008 12:11 am

Issue with DS Server Routine

Post by das_nirmalya »

I am using DataStage server routine to connect and extract data from DB2 table.

Its running fine when '1'='1' used in where clause
DB2CntCmd = " db2 connect to " :DBName : " user " :User : " using " : Password
ResultText = @Null
Call DSExecute("UNIX", DB2CntCmd, ResultText, SystemReturnCode)

RET_REQ = "db2 -x " : "'SELECT MAX ( LAST_UPDT_DT ) FROM OZR00UC1.OXIUPD WHERE '1' = '1' WITH UR'"

Call DSExecute("UNIX", RET_REQ , ResultText, SystemReturnCode)
Ans=ResultText

Return(Ans)

But facing issue when i am using below query
RET_REQ = "db2 -x " : "'SELECT MAX ( LAST_UPDT_DT ) FROM OZR00UC1.OXIUPD WHERE 'c' = 'c' WITH UR'"

Prob is - I am not able to use any kind of Varchar field in where clause of the query
nsd
qt_ky
Premium Member
Premium Member
Posts: 2895
Joined: Wed Aug 03, 2011 6:16 am
Location: USA

Post by qt_ky »

What is the issue? What do ResultText and SystemReturnCode show? Any specific error?
Choose a job you love, and you will never have to work a day in your life. - Confucius
das_nirmalya
Participant
Posts: 59
Joined: Thu Mar 20, 2008 12:11 am

Post by das_nirmalya »

Result = SQL0206N "C" is not valid in the context where it is used. SQLSTATE=42703




This is the error i am getting
nsd
qt_ky
Premium Member
Premium Member
Posts: 2895
Joined: Wed Aug 03, 2011 6:16 am
Location: USA

Post by qt_ky »

What happens if you replace the 'c' = 'c' part with an actual where clause using a real column from the table? First make sure to run the same statement successfully outside of the routine, for comparison.
Choose a job you love, and you will never have to work a day in your life. - Confucius
das_nirmalya
Participant
Posts: 59
Joined: Thu Mar 20, 2008 12:11 am

Post by das_nirmalya »

Then also its throwing same issue.
What i noticed if any varchar value used in where clause its giving issue.

Both of the below two statement running properly in DB2. But when i am using in rouitine 2nd one throwing issue

RET_REQ = "db2 -x " : "'SELECT MAX ( LAST_UPDT_DT ) FROM OZR00UC1.OXIUPD WHERE '1' = '1' WITH UR'"

RET_REQ = "db2 -x " : "'SELECT MAX ( LAST_UPDT_DT ) FROM OZR00UC1.OXIUPD WHERE 'c' = 'c' WITH UR'"
nsd
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

It looks like the internal single quotes are being stripped out. This is fine when "'1'" gets stripped to "1", but not when "'c'" get changed to "c".

Try doing

Code: Select all

\'c\'=\'c\'
p.s. SQL is removing those characters, not DataStage
Post Reply