Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: Run command on sqlplus repetitively without reconnection.
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_at_umb.com]
Sent: Wednesday, May 09, 2007 12:08 PM
To: Thotangare, Ajay (GTI); oracle-l_at_freelists.org
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_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/
-- http://www.freelists.org/webpage/oracle-lReceived on Wed May 09 2007 - 11:22:49 CDT
![]() |
![]() |