Skip to Main Content

Oracle Database Discussions

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!

Clear the session using plsql ,spool the result and execute sql file from procedure

N_RajJun 7 2018 — edited Jun 7 2018

Hi All,

We have oracle 11.2 on Linux.

We have many application. One of the application is muta.It does DML. Every day it runs 6 time.Normally takes less than 10 minutes.

Few occasion takes more than 2 hours to complete due to wrong sqlid. Then we clear that session.Maually do the DML statements.Then it works fine

I am asked to prepare the shell script to kill the session if runs more than 10 minutes and rerun the dml or run the .sql file ( it contains all DML related to the application)

Pleae check the below script and guide me

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

declare

cursor c1 is

select s.sid,s.serial# from v$session s where s.program like 'muta' and a.status ='ACTIVE' and s.last_call_et >= 600;

for c2 in c1

EXECUTE IMMEDIATE 'ALTER SYSTEM KILL SESSION '''|| c2.Sid || ',' || c2.Serial# || '''';

DML here.....

or

call the script here

end loop;

end;

/

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Are the above steps  right one?

How to spool  in plsql procedure

How to run the /uo1/script/test.sql file from procedure.

Any Suggestions

Thanks & Regards,

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 5 2018
Added on Jun 7 2018
3 comments
375 views