Running SQL command in a Routine

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
nkln@you
Premium Member
Premium Member
Posts: 271
Joined: Wed Nov 17, 2004 5:15 am
Location: US

Running SQL command in a Routine

Post by nkln@you »

I have written a code as follows in a routine

CMD= "SELECT * FROM abcd"
Call DSExecute("UV", CMD, result, sysreturncode)
Ans= result

When i tested the routine i am getting answer as 'SQL'. Why is it. What should i do if i need to get the output of SQL as the output of routine.


When i run the SQL COMMAND in Admiistrator, first it showed SQL, THEN after clicking Respond, it showed the correct answer.

What is wrong in my routine code.How should i alter it to get correct answer.
Aim high
WoMaWil
Participant
Posts: 482
Joined: Thu Mar 13, 2003 7:17 am
Location: Amsterdam

Post by WoMaWil »

Use the OPEN or OPENPATH-Statement in your Routine for reading Hashfiles, with those you get a higher flexibilty in your routines.
nkln@you
Premium Member
Premium Member
Posts: 271
Joined: Wed Nov 17, 2004 5:15 am
Location: US

Post by nkln@you »

Thanks WoMaWil ,


How can i know the path of the Hash file which i created in a DS job.
And also i don't have access to the server.

How to find the path of a hash file.


And also pls explain the usage of Open statement.
Aim high
WoMaWil
Participant
Posts: 482
Joined: Thu Mar 13, 2003 7:17 am
Location: Amsterdam

Post by WoMaWil »

Hashfiles can be written by two ways:

(1) In the Project Repository (to read it use the OPEN-Statement)
(2) In a Path (to read it use the OPENPATH-Statement)

The use of both statements is explained in detail in the documentation-pdf.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Re: Running SQL command in a Routine

Post by chulett »

nkln@you wrote:When i tested the routine i am getting answer as 'SQL'. Why is it.
Your answer is not 'SQL', it has put up an additional SQL prompt because your statement is incomplete.

Try adding a semi-colon to the end of your statement:

Code: Select all

CMD= "SELECT * FROM abcd;"
It should make it run but I doubt you are going to get what you are expecting. :? WoMaWil is trying to take you down the correct path, but it might help to know exactly where it is you want to go.

Can you explain what exactly it is you are trying to accomplish with this routine? Then people here can give you some guidance on the best way to accomplish that.
-craig

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