RE: Run command on sqlplus repetitively without reconnection.

  • From: "Kerber, Andrew W." <Andrew.Kerber@xxxxxxx>
  • To: Ajay_Thotangare@xxxxxx, oracle-l@xxxxxxxxxxxxx
  • Date: Wed, 9 May 2007 11:07:50 -0500

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: