Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Osql / rexx combo

Author  Topic 

bkpgamble
Starting Member

30 Posts

Posted - 2006-11-01 : 03:29:02
Dont know if this is the right forum to post this on but here we go.

I'am creating a rexx, and I need to use osql as well.
My problem is that I want the osql error message to be captured in rexx

like this
------------

sql = *sql statement*

"OSQL -S s122x98 -E -r 1 -w 200 -Q """sql""" | rxqueue" newq

sqlrc = rc

say 'sql rc' sqlrc

-------------

problem is the rexx, just says return code 0 even if the sql statement is invalid.

So how do I get the Osql error message into the RC of the rex ?

Thanks

robvolk
Most Valuable Yak

15732 Posts

Posted - 2006-11-01 : 07:58:13
Use the -o flag to pour the output into a file, then have your Rexx code use the file.
Go to Top of Page

bkpgamble
Starting Member

30 Posts

Posted - 2006-11-02 : 03:23:44
Yea proberly the way I'am going to do it just wanted to se if there was a nother way
Go to Top of Page

bkpgamble
Starting Member

30 Posts

Posted - 2006-11-08 : 05:06:05
I'am still having problems

I now use the -o c:\out.txt

and it dosent work as I would like it to
if I enter a valid osql command
ALTER INDEX [testI] ON [DRE].[TBtest] REORGANIZE
there is no output and the rexx runs fine

wenn I make the statement invalid
like
AL INDEX [testI] ON [DRE].[TBtest] REORGANIZE
I get an OSQL error and this error is NOT put into the output file as I would like but just printed on screen

how to I get this error into a file ?
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2006-11-08 : 07:57:14
I just ran a similar test and got error output in the file. You might need to use the -r and -m parameters to modify how errors are reported, Books Online describes them in more detail.
Go to Top of Page

bkpgamble
Starting Member

30 Posts

Posted - 2006-11-09 : 02:44:01
I already have them on but wenn I get anny error in my osql I still cant get it into the file

"OSQL -S Server -E -r 1 -m -n -w 200 -i c:\load2.sql -o c:\out.txt"

can you se were I did something wrong ?
Go to Top of Page

bkpgamble
Starting Member

30 Posts

Posted - 2006-11-09 : 02:45:57
Ahh I figured it out thanks :)
Go to Top of Page
   

- Advertisement -