Sqlplus cmd not returning control back to 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
maks475
Participant
Posts: 3
Joined: Wed Oct 28, 2009 12:59 am

Sqlplus cmd not returning control back to Routine

Post by maks475 »

Hi, calling sql query from a routine using sqlplus. routine run never ending.

Code:
Statement = "SELECT count(*) FROM TableName;"
Command = "sqlplus -S ": pSrcDBUser : "/" : pSrcDBPwd : pConString : char(10) : "SELECT count(*) FROM TableName;" : char(10) : "Exit" : char(10)
Call DSExecute ('NT', Command, OsOutput, OsStatus)

Above command will look before calling dsexecute as:
sqlplus -S UserName/Pwd@ConString
SELECT count(*) FROM TableName;
Exit

when I ran this directly from command prompt it is working fine and resulting record count. But when i call through DSExecute it is never ending the execution. I tried below as well but no luck. Please help.

Command = "sqlplus -S ": pSrcDBUser : "/" : pSrcDBPwd : pConString : char(10) : "SELECT count(*) FROM TableName;" : char(10) : "Exit" : char(10) : "Exit" : char(10)


Thanks in advance
Last edited by maks475 on Fri Jun 26, 2015 1:44 am, edited 1 time in total.
synsog
Premium Member
Premium Member
Posts: 232
Joined: Sun Aug 01, 2010 11:01 pm
Location: Pune

Re: Sqlplus cmd not returning control back to Routine

Post by synsog »

OsOutput will store the return value of query. You need to map this to another variable.
like
QueryResult = TRIM(FIELD,OsOutput,@FM,3))

YOu can pass this value to log

Call DSLogInfo("Result:":QueryResult, "JobStats")
maks475
Participant
Posts: 3
Joined: Wed Oct 28, 2009 12:59 am

Post by maks475 »

I do have such result printing statements but routine never ending the execution of the statement "DSExecute(...)" which is calling SQLPLUS.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Re: Sqlplus cmd not returning control back to Routine

Post by chulett »

maks475 wrote:when I ran this directly from command prompt it is working fine
Did you do this using the same user that executes the job?
-craig

"You can never have too many knives" -- Logan Nine Fingers
synsog
Premium Member
Premium Member
Posts: 232
Joined: Sun Aug 01, 2010 11:01 pm
Location: Pune

Post by synsog »

Provide your full routine. so that we can assess.
Post Reply