Read value in from SQL Server in 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
chinek
Participant
Posts: 75
Joined: Mon Apr 15, 2002 10:09 pm
Location: Australia

Read value in from SQL Server in Routine

Post by chinek »

Hi,
From my job sequence, I need to run a Routine first which will query a SQL server table and then pass the value from this routine into the job that will be run as one of the job parameters.

If it's Oracle I would be calling SQLPLUS from the Routine and using the ExecSH in Unix, but now that this table is in SQL Server(NT) what can I use to achieve the same thing ?
Please help.

Nick
loveojha2
Participant
Posts: 362
Joined: Thu May 26, 2005 12:59 am

Post by loveojha2 »

The tool would be isql.exe or osql.exe
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Use ExecDOS if on a Windows platform.

If you're writing for an unknown platform, then you would be better to create your own before/after subroutine.

Code: Select all

SUBROUTINE ExecOS(InputArg, ErrorCode)

* Test whether operating system is Windows or UNIX using System(91).
* Command variable included only as an example.

If System(91)
Then
   Shell = "DOS"
   Command = "DEL"
End
Else
   Shell = "UNIX"
   Command = "rm -rf"
End

* Execute command and set ErrorCode based on exit status.
* Enclosing InputArg in parentheses prevents side-effects.

Call DSExecute(Shell, (InputArg), Output, ExitStatus)
ErrorCode = ExitStatus

RETURN
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chinek
Participant
Posts: 75
Joined: Mon Apr 15, 2002 10:09 pm
Location: Australia

Post by chinek »

loveojha2 wrote:The tool would be isql.exe or osql.exe
Hi,
Are isql.exe or osql.exe available for Unix ? I am running DS7.5.1 on Solaris 8.

Nick
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

No, isql and osql are Windoze only. They come standard with the installation on the server.

You need to be able to run Windoze server commands from the unix box. The typical tools for this are rsh and remsh. It's kind of a security hassle to get a company to agree to enabling a user idea to execute remote commands on one server from the other when you're talking unix and Windoze. Unix to unix is never a problem, but those admins hate unix to Windoze. Once that's done, you'll need to write a script to execute the remsh command giving the exact syntax to run osql on the remote server doing whatever it is you need to do.

Your best option is to use a Server job to just spool the data to a file and then read the file from your routine. That's really clean and simple, but it doesn't give you the nice routine solution you like.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
Post Reply