dear zandyl,
u can use a button in the form for killing the session.
the code will be like this:
declare
cursor sess_cur
is select sid,serial#
from v$session
where username = 'ur specific user for which u want to kill the session'-- you may avoid this clause
-- to kill all the user's sessions.
and / or status = 'ACTIVE'/'INACTIVE';
--use this cluse to kill the
--sessions which are inactive
--or active,or u can avoid this
--caluse to kill all the session
v_sid number;
v_serial number;
v_st varchar2(100);
begin
open sess_cur; --open the cursor;
loop
fetch sess_cur into v_sid,v_serial; --fetch the cursor - --values into variables
exit when sess_cur%notfound;
v_stat := 'alter system kill
session '||''''||v_sid||','||v_ser
forms_ddl(v_stat);
end loop;
close sess_cur;
end;
here r some points for to notice:
1.if u can specifically select a singe combination of sid and serial# then u can use
a select statement with proper where clause in place of the cursor i used in the code.
but if the select statement returns more than 1 row or does not return any row then
an exception will be raised .then ur killing statement will not work.
2.there r some sessions available for which there is no username provided in the v$session.these
sessions, u can not kill.so u can use a where caluse - where username is not null.
3.for a single username there can be more than one session available in the v$session.so u can use
a where cluse to select only active sessions or inactive sessions.
i tested this method ,it works nice.
thanks
mehbub
Main Topics
Browse All Topics





by: pennnnPosted on 2003-03-24 at 10:21:17ID: 8197027
Dynamic SQL or forms_ddl:
EXECUTE IMMEDIATE 'alter system kill session ''23,123''';
FORMS_DDL('alter system kill session ''23,123'';');
The parameters for kill session are 'SID,SERIAL#'.
I'm not sure if the forms_ddl command requires a ; at the end of the statement.
Of course you'd need to have privileges to kill the session.
Hope that helps!