Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: Run command on sqlplus repetitively without reconnection.

RE: Run command on sqlplus repetitively without reconnection.

From: Kerber, Andrew W. <Andrew.Kerber_at_umb.com>
Date: Wed, 9 May 2007 11:07:50 -0500
Message-ID: <D40740337A3B524FA81DB598D2D7EBB307EF00D6@x6009a.umb.corp.umb.com>


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_at_freelists.org
[mailto:oracle-l-bounce_at_freelists.org] On Behalf Of Thotangare, Ajay (GTI)
Sent: Wednesday, May 09, 2007 10:23 AM
To: oracle-l_at_freelists.org
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.
--
http://www.freelists.org/webpage/oracle-l
Received on Wed May 09 2007 - 11:07:50 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US