Page 1 of 1

Read value in from SQL Server in Routine

Posted: Wed Nov 23, 2005 11:26 pm
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

Posted: Thu Nov 24, 2005 12:29 am
by loveojha2
The tool would be isql.exe or osql.exe

Posted: Thu Nov 24, 2005 3:18 am
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

Posted: Thu Nov 24, 2005 5:15 pm
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

Posted: Thu Nov 24, 2005 8:54 pm
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.