Skip to Main Content

SQL & PL/SQL

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!

To automate the SQL scripts using PLSQL Code

ShrmaJun 19 2013 — edited Jun 19 2013

Hi All,

I have 20 database server (11.2.0.3) hosted on  unix and Windows platforms.

Every day I have to kill inactive sessions from all the these 20 database servers. So I have made a below script::

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

connect sys/&&sys_password@&&tns_database_name as sysdba

SPOOL E:\DELETE_INACTIVE_SESSIONS.SQL

set PAGESIZE 1000

set LIN 5000

SET ECHO OFF;

SET FEEDBACK OFF;

SET HEADING OFF;

select 'alter system kill session '||'`'||SID||','||SERIAL#||'`'||' immediate;'  from v$session where status='INACTIVE' and username in ('OSS_DICTIONARY','ADMINISTRATOR');

SPOOL OFF;

@@E:\DELETE_INACTIVE_SESSIONS.SQL

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

Is there any way so that this execution of script can be automated in PLSQL code for 20 servers so and that code could be put in batch file for execution(i.e. can be execute through batch file from my windows laptop).

Thanks

This post has been answered by AlbertoFaenza on Jun 19 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 17 2013
Added on Jun 19 2013
5 comments
1,695 views