?
Solved

how to kill a session from a form????

Posted on 2003-03-24
2
Medium Priority
?
1,933 Views
Last Modified: 2013-12-12
hello oracle masters,
i'm trying to kill session from inside a form.  i'm currently using developer 6i ver with 8i database.  using a select in the sys.v$session, i know the pid and session no.  with this info, i need to do an 'alter system kill session...' statement but do not exactly know how.

do i just create a button and with the 'when button pushed trigger' type the command?  i'd really appreciate any comments....

zandy-
0
Comment
Question by:zandyl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 11

Expert Comment

by:pennnn
ID: 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!
0
 
LVL 1

Accepted Solution

by:
mahbub007 earned 500 total points
ID: 8206669
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_serial||''''; -- construct -                                        --the ddl statement
                 
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

 
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question