Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2004

    Red face Unanswered: 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,

  2. #2
    Join Date
    Apr 2004
    make a sql script which only outputs the single value you want:

    set timing off
    set feedback off
    set pages 0
    select sysdate from dual;

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts