Page 1 of 1

Sqlplus cmd not returning control back to Routine

Posted: Thu Jun 25, 2015 8:48 am
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

Re: Sqlplus cmd not returning control back to Routine

Posted: Thu Jun 25, 2015 12:55 pm
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")

Posted: Fri Jun 26, 2015 3:01 am
by maks475
I do have such result printing statements but routine never ending the execution of the statement "DSExecute(...)" which is calling SQLPLUS.

Re: Sqlplus cmd not returning control back to Routine

Posted: Fri Jun 26, 2015 6:31 am
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?

Posted: Fri Jun 26, 2015 8:20 am
by synsog
Provide your full routine. so that we can assess.