RE: Run command on sqlplus repetitively without reconnection.

  • From: "Thotangare, Ajay \(GTI\)" <Ajay_Thotangare@xxxxxx>
  • To: "Kerber, Andrew W." <Andrew.Kerber@xxxxxxx>, <oracle-l@xxxxxxxxxxxxx>
  • Date: Wed, 9 May 2007 12:22:49 -0400

I don't think execute immediate will run sqlplus command (spool command)

SQL> Begin

  FOR I in 1 .. 3 LOOP

        DBMS_OUTPUT.PUT_LINE('Value of I :'||I);

        Execute immediate 'spool test1.log';

  END LOOP;

End;

/

  2    3    4    5    6    7  Value of I :1

Begin

*

ERROR at line 1:

ORA-00900: invalid SQL statement

ORA-06512: at line 4

 

regards,

Ajay

  _____  

From: Kerber, Andrew W. [mailto:Andrew.Kerber@xxxxxxx] 
Sent: Wednesday, May 09, 2007 12:08 PM
To: Thotangare, Ajay (GTI); oracle-l@xxxxxxxxxxxxx
Subject: RE: Run command on sqlplus repetitively without reconnection.

 

Well, spool off will terminate spooling w/i oracle, but I think you may
need a stored procedure or anonymous block with an execute immediate
command to do what you are talking about, something like this.  Note, I
don't use execute immediate much so I don't promise anything::

 

Begin

  <looping logic here>

  Execute immediate('spool filename');

  Execute immediate('select event,count(*) from v$session group by
event');

  Execute immediate('spool off')

  Dbms_lock.sleep(2)

  <end looping logic here>

End

 

 

-----Original Message-----
From: oracle-l-bounce@xxxxxxxxxxxxx
[mailto:oracle-l-bounce@xxxxxxxxxxxxx] On Behalf Of Thotangare, Ajay
(GTI)
Sent: Wednesday, May 09, 2007 10:23 AM
To: oracle-l@xxxxxxxxxxxxx
Subject: Run command on sqlplus repetitively without reconnection.

 

I want to run a command on sqlplus without making re-connection. At the
same time I also want to see the output. 

I can do this using UNIX but only problem is I have to make reconnection
after every interval(which I don't want)

For e.g I run following script on unix prompt

#########################################################

while true

do

sqlplus -S "/as sysdba" <<EOF

select event,count(*) from v$session group by event;

exit;

EOF

sleep 2

done

#########################################################

I want to achive same functionality without making reconnection after
every 2 secs. 

I tried to use loop,spool file and dbms_lock.sleep() but spool file does
not display output till the procedure is completed

Can anybody help to achive this functionality ?

 

regards,

Ajay

 

  _____  

If you are not an intended recipient of this e-mail, please notify the
sender, delete it and do not read, act upon, print, disclose, copy,
retain or redistribute it. Click here <http://www.ml.com/email_terms/>
for important additional terms relating to this e-mail.
http://www.ml.com/email_terms/

  _____  

------------------------------------------------------------------------
------
NOTICE: This electronic mail message and any attached files are
confidential. The information is exclusively for the use of the
individual or entity intended as the recipient. If you are not the
intended recipient, any use, copying, printing, reviewing, retention,
disclosure, distribution or forwarding of the message or any attached
file is not authorized and is strictly prohibited. If you have received
this electronic mail message in error, please advise the sender by reply
electronic mail immediately and permanently delete the original
transmission, any attachments and any copies of this message from your
computer system. Thank you.

========================================================================
======

Other related posts: