Home » SQL & PL/SQL » SQL & PL/SQL » Time Out Or Kill the Session (Oracle 11 g Release 2)
Time Out Or Kill the Session [message #613181] Wed, 30 April 2014 11:12 Go to next message
azeem87
Messages: 116
Registered: September 2005
Location: dallas
Senior Member
hi,

Is there a way to timeout/Kill a Select Query after N number of mins,
this query will be fired from Apps.

for eg:-
A connection establised from an application, it does bunch of other stuff and then executes a select query, the moment this query is executed after N number
of minutes cancel this Query or close the connection.

Any thoughts.
Thanks
Re: Time Out Or Kill the Session [message #613183 is a reply to message #613181] Wed, 30 April 2014 11:25 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
http://www.oracle.com/pls/db121/search?word=profile
Re: Time Out Or Kill the Session [message #613185 is a reply to message #613181] Wed, 30 April 2014 11:33 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

You have PROFILE (see BlackSwan's link) or RESOURCE MANAGER for this.

PROFILE will kill the session, RESOURCE MANAGER will only kill the query.
PROFILE is easier to do, RESOURCE MANAGER is more accurate.

icon14.gif  Re: Time Out Or Kill the Session [message #613204 is a reply to message #613185] Wed, 30 April 2014 13:40 Go to previous messageGo to next message
azeem87
Messages: 116
Registered: September 2005
Location: dallas
Senior Member
Thanks All , Let me go through and see the best way we can do..

Really appreciate your quick response.
Re: Time Out Or Kill the Session [message #613376 is a reply to message #613204] Tue, 06 May 2014 01:42 Go to previous messageGo to next message
forums_man
Messages: 3
Registered: May 2014
Junior Member
first you need the block objects

SELECT   owner || '.' || object_name obj,
         oracle_username || ' (' || s.status || ')' oruser,
         os_user_name osuser, l.process unix,
         '''' || s.SID || ',' || s.serial# || '''' sid_and_serial, r.NAME rs,
         TO_CHAR (s.logon_time, 'yyyy/mm/dd hh24:mi:ss') TIME
    FROM v$locked_object l,
         dba_objects o,
         v$session s,
         v$transaction t,
         v$rollname r
   WHERE l.object_id = o.object_id
     AND s.SID = l.session_id
     AND s.taddr = t.addr
     AND t.xidusn = r.usn
ORDER BY osuser, sid_and_serial, obj



second yo have to kill session associated with blocked object

ALTER SYSTEM KILL SESSION 'sid_and_serial';


Regards


[EDITED by LF: fixed [code] tags.]

[Updated on: Tue, 06 May 2014 02:39] by Moderator

Report message to a moderator

Re: Time Out Or Kill the Session [message #613378 is a reply to message #613376] Tue, 06 May 2014 02:00 Go to previous message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Who say the session is "blocked"?
See the question "Kill a Select Query ", a SELECT is not blocked by any lock.

Also, Please How to use [code] tags and make your code easier to read.

Previous Topic: Oracle Alphanumeric Sequence
Next Topic: webservices
Goto Forum:
  


Current Time: Fri Apr 26 03:56:10 CDT 2024