If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Oracle > How to Return a Value from PL/Sql Script

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-29-04, 22:29
faisalee faisalee is offline
Registered User
 
Join Date: Sep 2004
Posts: 4
Red face How to Return a Value from PL/Sql Script

Hi Guys,

I have a PL/Sql script that I am calling from a Batch file (Win 2k), the script is being called at the start of the Batch file, I want to return a value from the SQL script and then check the return value in the Batch file.

How can I do this ?

I have the Sql Script and the Bat file ready, the only problem is the Integeration of these two

Thanks in Advance,
Faisal.
Reply With Quote
  #2 (permalink)  
Old 09-30-04, 09:49
shoblock shoblock is offline
Registered User
 
Join Date: Apr 2004
Posts: 246
make a sql script which only outputs the single value you want:

t.sql:
set timing off
set feedback off
set pages 0
select sysdate from dual;
exit


make a bat file as follows:
FOR /F "usebackq delims=!" %%i IN (`sqlplus -s u/p@db @t`) DO set xresult=%%i
echo %xresult%


the bat file will assign the final line of output to the variable xresult.
the "-s" option will prevent the "disconnected" message
in the FOR command, the "delims" option is used to override the default delimitor of whitespaces. this allows a string with spaces to be parsed as one variable (if you expect a "!", then choose something else, or leave it out completely if you won't haev whitespaces)
__________________
Give a man a fish, you feed him for a day. Club him over the head with a fish, he'll leave you alone.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On