Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Execute PLSQL Script from Batch File

achanaJul 16 2014 — edited Jul 17 2014

I am trying to execute a PL/SQL script in a batch file in Windows 7 Prof sp1

Step 1)  I wrote a simple PL/SQL script:

--

-- Scope of variables

--

DECLARE

  v_sal     number(7,2)   := 50000;

  v_comm    number(7,2)   := v_sal * .20;

  v_message varchar2(100) := ' eligible for commission';

BEGIN

  declare

    v_sal     number(7,2) :=50000;

    v_comm    number(7,2) :=0;

    v_total_comp  number(7,2) := v_sal+v_comm;

  begin

    v_message := 'Clerk not'||v_message;

    dbms_output.put_line ('Subblock message is '|| v_message);

    dbms_output.put_line ('Subblock v_comm is '|| v_comm);

  end;

  v_message := 'Salesman' || v_message;

  -- dbms_output.put_line ('Main block v_total_comp '|| v_total_comp); -- Error: not visible in main block

  dbms_output.put_line ('Main block v_comm '|| v_comm);

  dbms_output.put_line ('Main block message is '|| v_message);

END;

/

Step 2)  Then I wrote a simple batch file TstBatch.bat

sqlplus scott/tiger@orcl<PLSqlVarInputTst1.sql>>TstBatch.log

Step 3) In DOS cmd, I tried to execute TstBatch.bat

C:> TstBatch.bat

The log file tells me I have connected to Oracle Database 11g Enterprise Edition Release ...

Then a lot of SQL> SQL> SQL>... repeated 26 times

PL/SQL procedue successfully completed.

Disconnected from Oracle Database

I also tried executing the PLSQL script in SQLPlus:

SQL:>@PLSqlVarInputTst1.sql

Tells me the procedure successfully completed.

QUESTION: So where is the output from the PL/SQL script?

This post has been answered by RajenB on Jul 16 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 14 2014
Added on Jul 16 2014
5 comments
2,804 views