Procedure for Killing sessions

Hi All,
Almost everyday we have requirement to kill user sessions for dev user, I'm thinking to create a procedure for this and grant to the users so that they can kill it by themself.
Below is the what I got from Ask Tom forum, however appreciate if someone can share few information if already imlemented in there environment
<quote>
create or replace procedure kill_session( p_sid in number,
p_serial# in number)
is
ignore pls_integer;
BEGIN
select count(*) into ignore
from V$session
where username = USER
and sid = p_sid
and serial# = p_serial# ;
if ( ignore = 1 )
then
execute immediate '
alter system kill session ''' ||
to_char(p_sid,'999999')||','||
to_char(p_serial#,'999999')||'''';
else
raise_application_error( -20001,
'You do not own session ''' ||
p_sid || ',' || p_serial# ||
end if;
END;/
grant execute on kill_session to <username>
</quote>
Regards,
shaan

rp0428 wrote:
>
Instead of killing session with alter systemn kill session, better you opt for below two methods (still perform the same)
>
Please clarify what you mean. KILL and DISCONNECT do NOT perform the same.
From the SQL Language doc
http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_2013.htm
KILL is the nice one -
>
The KILL SESSION clause lets you mark a session as terminated, roll back ongoing transactions, release all session locks, and partially recover session resources
>
While DISCONNECT is the ogre
>
Use the DISCONNECT SESSION clause to disconnect the current session by destroying the dedicated server process (or virtual circuit if the connection was made by way of a Shared Sever).
>
The difference between the two is roughly analogous to the difference between SHUTDOWN IMMEDIATE and SHUTDOWN ABORT.
I agree that, for OPs use case DISCONNECT (with IMMEDIATE or POST TRANSACTION) may be better since it gets rid of things immediately while KILL can leave things hanging around for a while.From the same link:
DISCONNECT SESSION Clause:
The POST_TRANSACTION setting allows ongoing transactions to complete before the session is disconnected. If the session has no ongoing transactions, then this clause has the same effect described for as KILL SESSION.
The IMMEDIATE setting disconnects the session and recovers the entire session state immediately, without waiting for ongoing transactions to complete.
If you also specify POST_TRANSACTION and the session has ongoing transactions, then the IMMEDIATE keyword is ignored.
If you do not specify POST_TRANSACTION, or you specify POST_TRANSACTION but the session has no ongoing transactions, then this clause has the same effect as described for KILL SESSION IMMEDIATE.
basically the difference is not between DISCONNECT and KILL SESSION, the difference exists if you allow pending/ongoing transactions to finish(IMMEDIATE vs POST_TRANSACTION)
Edited by: Keilor on Jun 25, 2012 12:57 PM
Edited by: Keilor on Jun 25, 2012 1:39 PM

Similar Messages

  • Permissions for package owner for kill session?

    What permissions does a package owner need to execute immediate 'alter system kill session' within a package?

    Are you sure? It works for me on 10.2.0.1 (32 bit Windows)
    SYS @ jcave102 Local> drop user bob cascade;
    User dropped.
    Elapsed: 00:00:11.25
    SYS @ jcave102 Local> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    PL/SQL Release 10.2.0.1.0 - Production
    CORE    10.2.0.1.0      Production
    TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    Elapsed: 00:00:00.10
    SYS @ jcave102 Local> create user bob identified by bob default tablespace users;
    User created.
    Elapsed: 00:00:00.07
    SYS @ jcave102 Local> grant create session, create procedure, alter system to bob;
    Grant succeeded.
    Elapsed: 00:00:00.01
    SYS @ jcave102 Local> conn bob/bob
    Connected.
      1  create or replace procedure kill_session( p_sid in number, p_serial# in number )
      2  as
      3  begin
      4    execute immediate 'alter system kill session ''' || p_sid || ',' || p_serial# || '''';
      5* end;
    BOB @ jcave102  > /
    Procedure created.
    Elapsed: 00:00:00.57Now, find a session to kill (using a user other than BOB who doesn't have permission to view the V$SESSION table) and call the procedure
    BOB @ jcave102 Local> exec kill_session( 144, 115 );
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.00Justin

  • Procedure that kill session....

    Hello folks,
    how can i write a procedure that provoque the sql statment alter system kill session'159,554' immediate;
    i put it as it is in a pl/sql block but it gave error....
    please advise........

    Something like this ?
    SYS@db102 SQL> create or replace procedure killproc (
      2     sid_in          number,
      3     serial_in       number)
      4  is
      5  begin
      6     execute immediate ('alter system kill session '||chr(39)||sid_in||','||serial_in||chr(39));
      7* end;
    SYS@db102 SQL> /
    Procedure created.
    SYS@db102 SQL> select username,sid,serial#,status from v$session
      2  where username is not null;
    USERNAME                              SID    SERIAL# STATUS
    SYS                                   145        124 ACTIVE
    TEST                                  148         87 INACTIVE
    SYS@db102 SQL> exec killproc(148,87);
    PL/SQL procedure successfully completed.
    SYS@db102 SQL> select username,sid,serial#,status from v$session
      2  where username is not null;
    USERNAME                              SID    SERIAL# STATUS
    SYS                                   145        124 ACTIVE
    TEST                                  148         87 KILLED
    SYS@db102 SQL>                                                            

  • Clearing OS SPIDs for KILLED sessions

    Hi All,
    I had killed some sessions in the DB (10.2.0.3) and their status is set to KILLED in v$session.
    I am trying to find the OS PIDs of these sessions to do a "kill -9 " but I could not get them. I am using the below query which is not returning anything as the entry does not exist in v$process:
    select
    p.spid
    from v$session s, v$process p
    where p.addr = s.paddr
    and s.status='KILLED';
    Is there any way to get the OS PIDs of these sessions or to clear the KILLED rows from v$session without bouncing the database.
    Regards,
    Bharath.

    hi,
    once you kill the user then his process and memory will be released..
    post the output of v$session;
    regards,
    Deepak

  • ALTER SYSTEM KILL SESSION

    Hello Everybody,
    1) Is there any difference between “ALTER SYSTEM KILL SESSION & “kill -9”? Which one is the preferred method?
    2) When we do alter system kill 'sid, serial#'. Are we killing the user process or the server process?
    thanks in advance

    Welcome to the forum!
    Whenever you post provide your 4 digit Oracle version (result of SELECT * FROM V$VERSION)
    >
    Hello Everybody,
    1) Is there any difference between “ALTER SYSTEM KILL SESSION & “kill -9”? Which one is the preferred method?
    2) When we do alter system kill 'sid, serial#'. Are we killing the user process or the server process?
    >
    You should only use the 'kill' from the OS as a last resort.
    There are TWO Oracle options: KILL session and DISCONNECT session. Only rarely, in my experience will DISCONNECT SESSION not get the job done.
    See ALTER SYSTEM in the SQL Language doc
    http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_2013.htm
    >
    end_session_clauses
    The end_session_clauses give you several ways to end the current session.
    DISCONNECT SESSION Clause
    Use the DISCONNECT SESSION clause to disconnect the current session by destroying the dedicated server process (or virtual circuit if the connection was made by way of a Shared Sever). To use this clause, your instance must have the database open. You must identify the session with both of the following values from the V$SESSION view:
    •For integer1, specify the value of the SID column.
    •For integer2, specify the value of the SERIAL# column.
    If system parameters are appropriately configured, then application failover will take effect.
    •The POST_TRANSACTION setting allows ongoing transactions to complete before the session is disconnected. If the session has no ongoing transactions, then this clause has the same effect described for as KILL SESSION.
    •The IMMEDIATE setting disconnects the session and recovers the entire session state immediately, without waiting for ongoing transactions to complete.
    ◦If you also specify POST_TRANSACTION and the session has ongoing transactions, then the IMMEDIATE keyword is ignored.
    ◦If you do not specify POST_TRANSACTION, or you specify POST_TRANSACTION but the session has no ongoing transactions, then this clause has the same effect as described for KILL SESSION IMMEDIATE.
    See Also:
    "Disconnecting a Session: Example"
    KILL SESSION Clause
    The KILL SESSION clause lets you mark a session as terminated, roll back ongoing transactions, release all session locks, and partially recover session resources. To use this clause, your instance must have the database open. Your session and the session to be terminated must be on the same instance unless you specify integer3.You must identify the session with the following values from the V$SESSION view:
    •For integer1, specify the value of the SID column.
    •For integer2, specify the value of the SERIAL# column.
    •For the optional integer3, specify the ID of the instance where the target session to be killed exists. You can find the instance ID by querying the GV$ tables.
    If the session is performing some activity that must be completed, such as waiting for a reply from a remote database or rolling back a transaction, then Oracle Database waits for this activity to complete, marks the session as terminated, and then returns control to you. If the waiting lasts a minute, then Oracle Database marks the session to be terminated and returns control to you with a message that the session is marked to be terminated. The PMON background process then marks the session as terminated when the activity is complete.
    Whether or not the session has an ongoing transaction, Oracle Database does not recover the entire session state until the session user issues a request to the session and receives a message that the session has been terminated.
    See Also:
    "Terminating a Session: Example"
    IMMEDIATE Specify IMMEDIATE to instruct Oracle Database to roll back ongoing transactions, release all session locks, recover the entire session state, and return control to you immediately.

  • PL/SQL procedure to kill inactive session

    Hi all ,
    Please i am trying to write a procedure to kill inactive sessions of the shema 'TESTSCHEMA' .This is my first procedure , am not use to pl/sql but i went through many turtorial but have some errors at compliation .when i try to compile the procedure the errors are as below :
    15:50:28 Start Find Objects [TESTSCHEMA@TESTDB_UNIX(2)] ...
    15:50:28 End Find Objects [TESTSCHEMA@ TESTDB_UNIX(2)]
    15:50:32 Start Compiling 1 object(s) ...
    15:50:32 Executing ALTER PROCEDURE fib_dead_cnx_cleanup COMPILE ...
    15:50:32 [13:2] PL/SQL: ORA-00933: SQL command not properly ended
    15:50:32 [9:3] PL/SQL: SQL Statement ignored
    15:50:32 [18:12] PLS-00103: Encountered the symbol "(" when expecting one of the following:
    15:50:32 constant exception <an identifier>
    15:50:32 <a double-quoted delimited-identifier> table LONG_ double ref
    15:50:32 char time timestamp interval date binary national character
    15:50:32 nchar
    15:50:32 The symbol "<an identifier>" was substituted for "(" to continue.
    15:50:32 [18:21] PLS-00103: Encountered the symbol "LOOP" when expecting one of the following:
    15:50:32 := ; not null default character
    15:50:32 The symbol "; was inserted before "LOOP" to continue.
    15:50:32 [27:8] PLS-00103: Encountered the symbol "ALTER" when expecting one of the following:
    15:50:32 begin case declare exit for goto if loop mod null pragma
    15:50:32 raise return select update while with <an identifier>
    15:50:32 <a double-quoted delimited-identifier> <a bind variable> <<
    15:50:32 close current delete fetch lock insert open rollback
    15:50:32 savepoint set sql execute commit forall merge pipe
    15:50:32 Compilation complete - 5 error(s) found
    15:50:32 End Compiling 1 object(s)
    below is the procedure code :
    CREATE OR REPLACE
    PROCEDURE fib_dead_cnx_cleanup
    AS
    l_serial     CHAR(100);
    l_sid CHAR (100);
    l_sid_serial CHAR(100);
    l_count      NUMBER(10,0);
    CURSOR session_cur IS
              SELECT sid,serial#,sid||','||serial# as sid_serial
         FROM v$session
         WHERE username='EBBFCAT' and schemaname='TESTSCHEMA'
         and status='INACTIVE'
    BEGIN
         BEGIN
         l_count := 0;
                   OPEN session_cur;
                        WHILE ( 1 = 1) LOOP
                             BEGIN
                                  FETCH session_cur INTO l_sid ,l_serial,l_sid_serial ;
                                       EXIT WHEN session_cur%NOTFOUND ;
                                  BEGIN
                                       alter system kill session 'l_sid_serial' ;
                                  END;     
                             END;
                        END;
                   CLOSE session_cur;
         END;
    END FIB_DEAD_CNX_CLEANUP;
    Thanks

    Hi,
    Never write, let alone post, unformatted code.
    When posting any formatted text on this site, type these 6 characters:
    &#123;code&#125;
    (small letters only, inside curly brackets) before and after sections of formatted text, to preserve spacing.
    Among the benefits of formatting: you can indent to show the extent of blocks, such as BEGIN-END.
    Different types of blocks need modifiers after the end, such as "END *IF* " and " END *LOOP* ". If each opening statement (BEGIN, IF, LOOP) is directly above its corresponding END, then it's easy to check if you got the right modifier.
    Here's what you code looks like with some formatting, and a couple of corrections added. Look for -- comments.
    CREATE OR REPLACE
    PROCEDURE fib_dead_cnx_cleanup
    AS
         l_serial     CHAR(100);
         l_sid          CHAR (100);
         l_sid_serial     CHAR(100);
         l_count          NUMBER(10,0);
         CURSOR session_cur IS
                SELECT  sid
                ,       serial#
                ,       sid     || ','
                                      || serial#     as sid_serial
                FROM     v$session
                WHERE      username     = 'EBBFCAT'
                and     schemaname     = 'TESTSCHEMA'
                and     status          = 'INACTIVE';          -- need semicolon here
    BEGIN
         BEGIN                                   -- Why?
              l_count := 0;
              OPEN session_cur;
              WHILE ( 1 = 1)
              LOOP
                    BEGIN                         -- Why?
                         FETCH  session_cur
                         INTO   l_sid
                         ,          l_serial
                         ,          l_sid_serial ;
                               EXIT WHEN session_cur%NOTFOUND ;
                         BEGIN                    -- Why?
                             alter system kill session 'l_sid_serial' ;    -- Not a PL/SQL command
                               END;
                          END;
                END LOOP;                         -- LOOP ends with END LOOP
                CLOSE session_cur;
            END;
    END      FIB_DEAD_CNX_CLEANUP;Take baby steps.
    I've been wrtiing PL/SQL for 20 years, and I would never write that much code at once. If you're a beginner, all the more reason to start small. Write as little as possible, test, debug and test again (if necessary). When you have someting working, add 2 or 3 more lines and test again.
    It looks like you have three BEGIN statements that don't serve any purpose. You should get rid of them (and their corresponding END statements, of course).
    One error I did not fix: ALTER SYSTEM is not a PL/SQL statement. It's a SQL statement. You can run a SQL statement inside PL/SQL by using dynamic SQL, where you construct a string containing the SQL statement, and then use dbms_sql or EXECUTE IMMEDIATE to run it.
    Edited by: Frank Kulash on Aug 18, 2009 12:37 PM

  • Procedure to kill a session

    I do not have priviledge to kill the session, and i have checked the forums to create a procedure to kill the session,
    so how can i use that procedure to kill the session.
    Thanks

    If you should be allowed to kill sessions, then your DBA will grant you the ALTER SYSTEM privilege. Or, you could request your DBA to create a stored procedure for it and then grant you execute permission on that procedure. Of course, if your DBA does not choose to do this, then this is a discussion you should be having with your management.

  • KILL SESSION Procedure

    i have created a procedure that I will check for open sessions and then kill them. I tried to compile this procedure using sqldeveloper and the output i got was Warning: execution completed with warning. package body Compiled. I then go and look for the package and i don't see it on the database. Here is my package and procedure...what am i doing wrong here? Is my syntax incorrect?
    create or replace
    package body pkg_sess_kill as
    procedure sp_sess_kill is
    --DECLARE
    v_sid number;
    v_serial# number;
    v_username varchar2(30);
    CURSOR checkuser IS
    select sid,serial#,username
    from v$session
    where username IN ('CMSLOGGER',
    'CMS2WIRE',
    'SMS2WIRE');
    BEGIN
    OPEN checkuser;
    FETCH checkuser into v_sid,v_serial#,v_username;
    EXIT when checkuser%NOTFOUND;
    IF v_username is not null THEN
    ALTER SYSTEM KILL SESSION 'v_sid,v_serial#' IMMEDIATE;
    END IF;
    CLOSE checkuser;
    END sp_sess_kill;
    END pkg_sess_kill;

    I understand that this is probably not the best way to address my problem. I am just starting off and still learning. I honestly just want my procedure to work and don't understand why it doesn't. I will look into other alternatives, but still would like to understand why it doesn't work.
    Here is my procedure that will check for open sessions by particular usernames, and then kill the sessions if these usernames exist in the v$session view.
    create or replace
    procedure sp_sess_kill AS
    --DECLARE
    v_sid number;
    v_serial# number;
    v_username varchar2(30);
    CURSOR checkuser IS
    select sid,serial#,username
    from v$session
    where username IN ('USER1',
    'USER2',
    'USER3');
    BEGIN
    OPEN checkuser;
    LOOP
    FETCH checkuser into v_sid,v_serial#,v_username;
    EXIT when checkuser%NOTFOUND;
    IF v_username is not null THEN
    execute immediate 'alter system kill session '||chr(39)||v_sid||','||v_serial#||chr(39);
    END IF;
    END LOOP;
    CLOSE checkuser;
    END sp_sess_kill;
    The problem now is that i am getting the error msgs:
    Error(8,15): PL/SQL:SQL Statement Ingored
    Error(9,20): PL/SQL: ORA-00942: table or view does not exist.
    This is odd because when i run the sql by itself outside the procedure block, i get a result set:
    SID SERIAL# USERNAME
    511 5105 USER1
    516 7875 USER2
    Please advise.

  • How to know (package , procedures or functions) name for current sessions

    Hi all
    I'm DBA and i want to find way to get object name whatever (package , procedures or functions) for current running statement in active session.
    To clarify when i open session browser from toad i can see active sessions and see current statement for every session but without the name of the object.
    Is there any way to know this point.
    thanks in advance

    select *
      from dba_objects
    where object_id in (select nvl(t.PLSQL_ENTRY_OBJECT_ID,-1)
                           from v$session t
                          where sid = 452)
    Ramin Hashimzade

  • Clear the entry for killed/sniped session in v$session

    Dear all,
    In our production database(11.2.0.1.0) running on windows 2008 server many client session showing inactive from last 4-5 hour and I want to kill those session because all sessions are dedicated so for this I created a resource plan set its idle time after certain interval session status is showing killed but it is not removing entries from v$session but our client demand is it must be clear from v$session so for this i was using DOS command taskkill utility to kill particular os process so I want to know what is the smartest way to do this.

    This is known behavior, not an issue.
    In a dedicated server environment when the session is killed and the rollback completes the process goes away so a join between v$session and v$process will fail. The v$session entry also usually goes away rather quickly, though I have seen cases where the v$session entry hung around till the instance was bounced. But normally Oracle will overlay the v$session entry with a new session using the same sid but a different serial# within seconds on a busy system.
    Mark @ http://dbaspot.com/oracle-server/40419-killed-sessions.html
    Metalink doc id 1023442.6 is also something confirming it.
    See also below link and last reply by Mr. Braj Kishore Mahto.
    http://dbaforums.org/oracle/index.php?showtopic=3039
    Regards
    Girish Sharma
    Edited by: Girish Sharma on Nov 21, 2012 5:35 PM
    So, what is best in this regard :
    ALTER SYSTEM DISCONNECT SESSION
    The ALTER SYSTEM DISCONNECT SESSION syntax is an alternative method for killing Oracle sessions. Unlike the KILL SESSION command which asks the session to kill itself, the DISCONNECT SESSION command kills the dedicated server process (or virtual circuit when using Shared Sever), which is equivalent to killing the server process from the operating system. The basic syntax is similar to the KILL SESSION command with the addition of the POST_TRANSACTION clause. The SID and SERIAL# values of the relevant session can be substituted into one of the following statements.
    SQL> ALTER SYSTEM DISCONNECT SESSION 'sid,serial#' POST_TRANSACTION;
    SQL> ALTER SYSTEM DISCONNECT SESSION 'sid,serial#' IMMEDIATE;
    http://www.oracle-base.com/articles/misc/killing-oracle-sessions.php#disconnect_session

  • "Handling" Killed Sessions

    I'm curious as to if anybody has some insight to killed sessions. I have a procedure that looks like this:
    procedure x
      lv_result number;
      lv_msg varchar2(4000);
      for x in cursor
      loop
        lv_result := NULL;
        lv_msg := NULL;
        begin
          execute immediate x.sql into lv_result;
        exception
          when others then
             lv_msg := dbms_utility.format_error_stack;
             lv_result = NULL;
        end;
        log_result;  --autonomous transaction that inserts to table and commits;
      end loop;
      print_summary;
    end x;What struck me as odd was that even though I'd kill the session while it was in the middle of processing rec 10 out of 30, it would still log the remaining 20 records with a "ORA-00028: your session has been killed" message. But it didn't print the results. So modified it a bit...
    procedure x
      SESSION_KILLED exception ;
      pragma exception_init(SESSION_KILLED, -28);
      lv_result number;
      lv_msg varchar2(4000);
      lv_session_killed boolean := FALSE;
      for x in cursor
      loop
        lv_result := NULL;
        lv_msg := NULL;
        begin
          execute immediate x.sql into lv_result;
        exception
          when session_killed then
             lv_session_killed := TRUE;
             lv_msg := dbms_utility.format_error_stack;
             lv_result = NULL;
          when others then
             lv_msg := dbms_utility.format_error_stack;
             lv_result = NULL;
        end;
        log_result; --autonomous transaction that inserts to table and commits;
        exit when lv_session_killed;
      end loop;
      print_summary;
    end x;...which effectively stopped the loop at the first record in the cursor at which the session was killed, and still didn't print the summary. But it's obvious that processing still "continues" in the background even though the session was killed. Does killing the session just terminate communications between the client and the DB, letting the procedure to continue on it's own? Is there any way to get DBMS_OUTPUT calls to work before the procedure actually dies?

    Database is 10.2.0.4.0
    Here's a quickie example:
    drop table tst_output;
    create table tst_output (num number, msg varchar2(4000));
    create or replace procedure p1
    as
      -- Make killed session named exception
      SESSION_KILLED exception ;
      pragma exception_init(SESSION_KILLED, -28);
      -- Random query to generate string (a little slowly on my dev box).
      lv_sql varchar2(4000) := 'select case when cnt is not null then ''SUCCESS!'' end as dummy_data ' ||
                               'from (select count(*) cnt from all_objects ' ||
                               'where last_ddl_time > (select min(last_analyzed) from all_tables))';
      lv_return tst_output.msg%type;        --result of execute immedaite
      lv_session_killed boolean := FALSE;   --stop processing if session killed.
      procedure insert_rec (
        p_num in tst_output.num%type,
        p_msg in tst_output.msg%type)
      as
        pragma autonomous_transaction;
      begin
        insert into tst_output (num, msg)
        values (p_num, p_msg);
        commit;
      end insert_rec;
      procedure print_something
      as
      begin
        for x in (select msg from tst_output)
        loop
          dbms_output.put_line(x.msg);
        end loop;
      end print_something;
    begin
      execute immediate 'truncate table tst_output';
      for x in 1 .. 30  -- or however many loops it takes that you can jump to another window
      loop
        begin
          execute immediate lv_sql into lv_return;
        exception
          when SESSION_KILLED then
            lv_session_killed := TRUE;
            lv_return := dbms_utility.format_error_stack;
            dbms_output.put_line('Kill Time: ' || to_char(sysdate, 'dd-mon-yyyy'));
          when OTHERS then
            lv_return := dbms_utility.format_error_stack;
        end;
        insert_rec(x, lv_return);
        --exit when lv_session_killed;
      end loop;
      print_something; 
      dbms_output.put_line('Finish Time: ' || to_char(sysdate, 'dd-mon-yyyy'));
    end p1;Run this with a high enough loop count that you can jump to another window and kill that session...
    ALTER SYSTEM KILL SESSION 'SID, SERIAL'If you log back in (disconnected from the session kill) and look a the tst_output table, you'll still see 1 record for every loop. If you uncomment the EXIT towards the end of the actual executable portion and do it again, the program will break from the loop when you kill the session.
    So that means that the inner exception handler is catching the SESSION_KILLED_EXCEPTION, but
    1) DBMS_OUTPUT in the exception is not displayed
    2) It doesn't return to the normal flow after it is handled because the print at the bottom isn't displaying either.
    The session running the procedure is killed (and disconnected), but doesn't get the DBMS_OUTPUT before it's disconnected...and the procedure continues processing till it's done?

  • Killing Session : Form vs TOAD

    1. How to distingusih between Form Session and Toad Session?
    2. How to know if a session is being locked?
    My problem is to kill locked session using a scheduler. Tx in advance.

    CREATE OR REPLACE PROCEDURE FIFAPPS.fs_p_kill_idle_session
    IS
    BEGIN
       FOR pr IN (SELECT TO_NUMBER (value) waktu
                    FROM fifapps.FS_MST_PARAM a
                   WHERE MODULE_ID = 1
                     AND key = 'AUTO_KILL'
                     AND TO_NUMBER (value) > 0)
       LOOP
          FOR ss IN (SELECT SID, serial#,
                            ROUND (seconds_in_wait / 60, 2) minutes_wait, event,
                            machine, program, action, module
                       FROM v$session
                      WHERE service_name <> 'SYS$BACKGROUND'
                        AND event = 'SQL*Net message from client'
                        AND status <> 'KILLED'
                        AND upper(program) NOT LIKE '%TOAD%'
                        AND seconds_in_wait > pr.waktu)
          LOOP
             EXECUTE IMMEDIATE    'alter system kill session '''
                               || ss.SID
                               || ','
                               || ss.serial#
                               || '''';
          END LOOP;
       END LOOP;
    END;
    /I found the code above.. and some users said that the TOAD session is killed as well...

  • How do I keep a page as my home page when dragging icon to left of URL to house image & confirming that I want it as home page works only for current session, so when Firefox next opened, I end up with some stupid search page which McAfee doesn't like?

    A couple of days ago, I connected to the Internet as usual & opened Firefox, only to be greeted by an almost blank screen with a Google-type search box in the middle & this message from McAfee:
    "Your default search settings have changed. This may pose a security risk. Would you like to restore them to McAfee Secure Search to provide a safer searching experience?"
    instead of my usual home page (BT Yahoo). I naturally clicked on the "Yes" option in the message, but rather than restoring my BT Yahoo home page, all that did was to insert the McAfee logo to the left of the search box in the top right-hand corner of the screen. The first time it happened, I had to search for the BT Yahoo page & then followed the standard procedure for setting it again as my home page. It worked only for that session: each time I shut down Firefox or restarted my computer after that, all I got was the blank "search page" & restoring the previous session was the only way to get back to BY Yahoo. How on earth do I make the home page setting permanent?
    As far as I'm aware, I have done nothing to alter my search settings. However, I am anything but computer-literate, so I may have done/pressed something without realising it, but trying to understand what is now happening is far beyond my limited IT skills.

    See McAfee support to find out how to disable that McAfee feature - that isn't part of the normal Firefox installation.

  • How can I get the elapse time for execution of a Query for a session

    Hi ,
    How can I get the elapse time for execution of a Query for a session?
    Example - I have a report based on the procedure ,when the user execute that it takes say 3 min. to return rows.
    Is there any possible way to capture this session info. for this particular execution of query along with it's execution elapse time?
    Thanks in advance.

    Hi
    You can use the dbms_utility.get_time tool (gives binary_integer type value).
    1/ Initialize you time and date of beginning :
    v_beginTime := dbms_utility.get_time ;
    2/ Run you procedure...
    3/ Get end-time with :
    v_endTime := dbms_utility.get_time ;
    4/ Thus, calculate elapsed time by difference :
    v_elapsTime := v_endTime - v_beginTime ;
    This will give you time elapsed in of 100th of seconds...
    Then you can format you result to give correct print time.
    Hope it will help you.
    AL

  • How to kill session in forms

    In my application I want to kill session if any user
    is idle for 2 minutes.
    I am using oracle forms 6i and database oracle 9i

    You have to use D2KWutil.pll
    In when new form instance write the following code
    declare
    hWind PLS_INTEGER;
    CheckTimer TIMER;
    begin
    hWind := get_window_property(FORMS_MDI_WINDOW,WINDOW_HANDLE);
    Win_API_Session.Timeout_Start_Timer(hWind);
    CheckTimer := Create_Timer('CheckTimeout',1000,repeat);
    end;
    and in when timer expired trigger write the following code
    begin
    if upper(get_application_property(TIMER_NAME)) = 'CHECKTIMEOUT' then
                   :timer.t1 := Win_api_session.Timeout_Get_Inactive_Time;     
    if :timer.t1 > 120 then -- timer is a block and t1 is text item (don't assign a canvas to it, make it invisible)
    Win_API_Session.timeout_delete_timer;
    exit_form (NO_VALIDATE);
    end if;
    end if;
    end;
    hope this helps !!

Maybe you are looking for