<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	>
<channel>
	<title>Comments on: What happens when a session is killed?</title>
	<atom:link href="http://oraqa.com/2006/01/18/what-happens-when-a-session-is-killed/feed/" rel="self" type="application/rss+xml" />
	<link>http://oraqa.com/2006/01/18/what-happens-when-a-session-is-killed/</link>
	<description>Oracle Question and Answer</description>
	<pubDate>Tue, 06 Jan 2009 10:43:22 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: bob</title>
		<link>http://oraqa.com/2006/01/18/what-happens-when-a-session-is-killed/comment-page-1/#comment-108</link>
		<dc:creator>bob</dc:creator>
		<pubDate>Mon, 06 Feb 2006 18:00:07 +0000</pubDate>
		<guid isPermaLink="false">http://oraqa.com/2006/01/18/what-happens-when-a-session-is-killed/#comment-108</guid>
		<description>In some circumstances you don't want your killed sessions to hang around there until restart. For example in our application we had a restriction that a user can only open 2 sessions to the database and these zombies prevented a user from logging on. If you want to make sure the session you are killing actually keels over instantly do not issue 'kill session'. Instead get PID of the process (on UNIX) from v$process.spid (join to v$session to get your session) and kill the process first using OS kill command. Then issue 'kill session'. 

Vadim Bobrov</description>
		<content:encoded><![CDATA[<p>In some circumstances you don&#8217;t want your killed sessions to hang around there until restart. For example in our application we had a restriction that a user can only open 2 sessions to the database and these zombies prevented a user from logging on. If you want to make sure the session you are killing actually keels over instantly do not issue &#8216;kill session&#8217;. Instead get PID of the process (on UNIX) from v$process.spid (join to v$session to get your session) and kill the process first using OS kill command. Then issue &#8216;kill session&#8217;. </p>
<p>Vadim Bobrov</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pmoore</title>
		<link>http://oraqa.com/2006/01/18/what-happens-when-a-session-is-killed/comment-page-1/#comment-81</link>
		<dc:creator>pmoore</dc:creator>
		<pubDate>Mon, 23 Jan 2006 16:01:19 +0000</pubDate>
		<guid isPermaLink="false">http://oraqa.com/2006/01/18/what-happens-when-a-session-is-killed/#comment-81</guid>
		<description>One thing to watch for - the killed session receives a "Your session has been killed" error. It is possible to trap that error in PL/SQL (although, obviously, not to do anything particularly meaningful with it...)

Badly-written PL/SQL, which uses &lt;pre&gt;exception when others =&#62;&lt;/pre&gt; can therefore end up in an infinite loop when killed.</description>
		<content:encoded><![CDATA[<p>One thing to watch for - the killed session receives a &#8220;Your session has been killed&#8221; error. It is possible to trap that error in PL/SQL (although, obviously, not to do anything particularly meaningful with it&#8230;)</p>
<p>Badly-written PL/SQL, which uses
<pre>exception when others =&gt;</pre>
<p> can therefore end up in an infinite loop when killed.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: troach</title>
		<link>http://oraqa.com/2006/01/18/what-happens-when-a-session-is-killed/comment-page-1/#comment-59</link>
		<dc:creator>troach</dc:creator>
		<pubDate>Wed, 18 Jan 2006 19:08:52 +0000</pubDate>
		<guid isPermaLink="false">http://oraqa.com/2006/01/18/what-happens-when-a-session-is-killed/#comment-59</guid>
		<description>Nice script.

Here is a script I use to log users off the database. I could combine the two and it might be a nicer script! :)

ALTER SYSTEM KILL SESSION 
(SELECT s.sid,
        s.serial#
 FROM   v$session s
 WHERE UPPER(s.username) = UPPER('SYSTEM')
/


create or replace procedure set_udump( p_udump in varchar2 )
  2  as
  3  begin
  4    execute immediate 'alter system set user_dump_dest = ''' &#124;&#124; p_udump 
                                    &#124;&#124; ''' scope=memory';
  5  end;
  6  /

GRANT ALTER SYSTEM TO someuser;
GRANT SELECT ON v$_session to someone;

CREATE OR REPLACE PROCEDURE drop_user 
(p_drop_user IN VARCHAR2)

AS

v1_sid     number;
v1_serial  number;


CURSOR C1 
IS
SELECT  s.sid,
        s.serial#
 FROM   v$session s
 WHERE UPPER(s.username) = UPPER(p_drop_user);
 
BEGIN 	
 	
OPEN C1;
	
LOOP
  
FETCH C1 INTO v1_sid, v1_serial;

EXIT WHEN C1%NOTFOUND;

EXECUTE IMMEDIATE 'ALTER SYSTEM KILL SESSION ''' &#124;&#124; v1_sid &#124;&#124; ', ' &#124;&#124; v1_serial &#124;&#124; '''';

END LOOP;
CLOSE C1;
COMMIT;
END;</description>
		<content:encoded><![CDATA[<p>Nice script.</p>
<p>Here is a script I use to log users off the database. I could combine the two and it might be a nicer script! :)</p>
<p>ALTER SYSTEM KILL SESSION<br />
(SELECT s.sid,<br />
        s.serial#<br />
 FROM   v$session s<br />
 WHERE UPPER(s.username) = UPPER(&#8217;SYSTEM&#8217;)<br />
/</p>
<p>create or replace procedure set_udump( p_udump in varchar2 )<br />
  2  as<br />
  3  begin<br />
  4    execute immediate &#8216;alter system set user_dump_dest = &#8221;&#8217; || p_udump<br />
                                    || &#8221;&#8217; scope=memory&#8217;;<br />
  5  end;<br />
  6  /</p>
<p>GRANT ALTER SYSTEM TO someuser;<br />
GRANT SELECT ON v$_session to someone;</p>
<p>CREATE OR REPLACE PROCEDURE drop_user<br />
(p_drop_user IN VARCHAR2)</p>
<p>AS</p>
<p>v1_sid     number;<br />
v1_serial  number;</p>
<p>CURSOR C1<br />
IS<br />
SELECT  s.sid,<br />
        s.serial#<br />
 FROM   v$session s<br />
 WHERE UPPER(s.username) = UPPER(p_drop_user);</p>
<p>BEGIN 	</p>
<p>OPEN C1;</p>
<p>LOOP</p>
<p>FETCH C1 INTO v1_sid, v1_serial;</p>
<p>EXIT WHEN C1%NOTFOUND;</p>
<p>EXECUTE IMMEDIATE &#8216;ALTER SYSTEM KILL SESSION &#8221;&#8217; || v1_sid || &#8216;, &#8216; || v1_serial || &#8221;&#8221;;</p>
<p>END LOOP;<br />
CLOSE C1;<br />
COMMIT;<br />
END;</p>
]]></content:encoded>
	</item>
</channel>
</rss>
