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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

How to use spool or any workaround inside pl/sql

perfdbaJan 9 2017 — edited Jan 26 2017

Hi Friends,

I am trying to use the spool command to spool multiple sql statements into one file and then want to do some analysis on that sql text by using shell scripts.

Problem is i am not able to generate a separate spool file in pl/sql . i googled and found that we cannot use sqlplus command inside pl/sql.

Can anyone please suggest me some workaround to achieve my objective?

Below is simplified code for showing what i want to get.

set serveroutput on

declare

i number:=0;

begin

for s in 1..10

loop

  i:= i+ 1;

  execute immediate 'spool querytext_'||i||'';

  dbms_output.put_line(chr(10));

  dbms_output.put_line(i);

  end loop;

end;

/

Regds.

Sachin

This post has been answered by Frank Kulash on Jan 9 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 23 2017
Added on Jan 9 2017
11 comments
2,805 views