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>                                                            

Similar Messages

  • 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

  • Killed session still showing in V$session

    I have killed some 5 sessions. Its status is reflecting as KILLED for last 10 days. I searched for the relevant OS process to completely scratch the session. But it returned none.
    Now i have that KILLED session in V$session view and no process from OS level.
    How can i remove that KILLED entry from v$session view?

    Those status KILLED in your V$SESSION you will have to kill them by the Operation System (kill -9 "spid"). So, you'll have to find in the V$PROCESS the SPID (process number) from the 5 killed session that you have. In a normal situation, with statuses ACTIVE or INACTIVE, you can easily find the SPID with:
    "select p.spid, s.username, s.status from v$process p, v$session s where s.paddr=p.addr".
    But, sometimes, when you have "KILLED" sessions for a long time, this link between both dict views are lost and you have to find all the SPID that doesn not have child record on v$session.
    You have to do this carefully, because you cannot kill (on OS) the Oracle Processes (pmon, dbwr, etc..).
    Paulo.

  • 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.

  • Urgent-how to run 'alter system kill session 'sid, serial#' in form 6i ?

    I want to write a procedure in Form 6i so that user can kill the session by herself.
    I know kill session sql is 'alter system kill session 'sid, serial#'', however, I fould that I can only run it it sql plus screen, how can I run it in Form or in Stored procedure?
    Urgent....Please!

    try using Forms_ddl('alter system......'); in the forms. it will execute the dml statements in the form.
    zaibi.

  • Batch kill session

    Hi,
    How can I batch kill session?
    I have two related sessions in v$session by column client_info.
    When os administrator kill the process, only kill the first session. I need to execute automatically the procedure:
    psid number;
    pserial# number;
    session_killed EXCEPTION;
    PRAGMA EXCEPTION_INIT(session_killed, -31);
    begin
    SELECT sid, serial# into psid, pserial# FROM v$session WHERE client_info = p_client_info;
    EXECUTE IMMEDIATE 'alter system kill session ' || '''' || psid || ',' || pserial# || ''' immediate';
    DBMS_OUTPUT.PUT_LINE('Killing user ' || psid || ', ' || pserial#);
    EXCEPTION
    WHEN session_killed THEN
    DBMS_OUTPUT.PUT_LINE('The session ' || psid || ' has been marked to be killed');
    END;
    It is possible?
    Help me, pls
    Beatriz

    Hi!
    Pierre Forstmann, I have proven it, but I think that the trigger does not activate when kill becomes from the os.
    -Sri, I'm executing a mapping of owb in production through a function.
    The function generates one session in the data base and the call to mapping another one.
    When mapping takes much, the production operators make kill process by means of a tool (controlM) that only suspends the first session.
    But mapping continues executing itself because it runs under the other session.
    I have related both sessions to identify them through the column client_info of v$session, now Its necessary automatically kill the second session, but I don't know how to do it.
    thanks to all

  • "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...

  • Kill session without permission

    I have a procedure that sometimes won't to finish :) I have no permission to kill the session. Can I set a time, that after it procedure will be end or sht like this?

    Take a look at "sniping" jobs with max_run_duration on this link:
    [url http://tonguc.wordpress.com/2008/09/03/max_run_duration-attribute-of-the-scheduler-to-setup-a-sniper-job/]max_run_duration and a sniper job

  • A killed session is still waiting for "library cache lock" for hours

    Hello everybody
    Today on my environment I killed a session while compiling a procedure that was taking too much time. Now, after more than a couple of hours that session is still there waiting for "library cache lock". I really can't understand why it's taking that much. Can anyone give me some hints about this. I already read the docs to find something to explain this case but I haven't been able to find the source of this lock.
    Down here I past a description of what that procedure has been doing.
    Processing ...
    SELECT saddr, SID, command,taddr,lockwait,status,action
    FROM v$session
    WHERE SID = 636
    Query finished, retrieving results...
          SADDR      SID     COMMAND         TADDR      LOCKWAIT   STATUS              ACTION
    C00000023C7A2438     636        24 C000000238FB1650          KILLED   Main session      
    1 row(s) retrieved
    Processing ...
    SELECT *
    FROM v$session_wait
    WHERE SID = 636
    Query finished, retrieving results...
    SID SEQ# EVENT               P1TEXT         P1                   P1RAW            P2TEXT       P2                   P2RAW            P3TEXT             P3  P3RAW            WAIT_CLASS_ID  WAIT_CLASS#   WAIT_CLASS   WAIT_TIME SECONDS_IN_WAIT  STATE
    636 247  library cache lock  handle address 13835058063333980008 C0000001DFECF768 lock address 13835058064378433728 C00000021E2E10C0 100*mode+namespace 301 000000000000012D 3875070507     4             Concurrency  38        6089            WAITED KNOWN TIME
    1 row(s) retrieved
    Processing ...
    select *
    from v$session_event
    where sid = 636
    Query finished, retrieving results...
    SID EVENT                         TOTAL_WAITS TOTAL_TIMEOUTS TIME_WAITED AVERAGE_WAIT MAX_WAIT TIME_WAITED_MICRO   EVENT_ID WAIT_CLASS_ID WAIT_CLASS# WAIT_CLASS
    636 db file sequential read                 3              0           4          1,5        3             44994 2652584166    1740759767           8  User I/O  
    636 library cache lock                     58             57       16737       288,56      293         167366653  916468430    3875070507           4  Concurrency
    636 SQL*Net message to client              94              0           0            0        0                46 2067390145    2000153315           7  Network   
    636 SQL*Net more data to client            25              0           0            0        0               294  554161347    2000153315           7  Network   
    636 SQL*Net message from client            94              0        2848         30,3     2246          28480966 1421975091    2723168908           6  Idle      
    636 SQL*Net more data from client          28              0           0         0,02        0              4471 3530226808    2000153315           7  Network   
    636 SQL*Net break/reset to client           2              0           0         0,01        0               194 1963888671    4217450380           1  Application
    7 row(s) retrieved                            Thanks
    Bye Alessandro
    Edited by: Alessandro Rossi on 11-nov-2008 11.37

    Alessandro Rossi wrote:
    At the end I decided to kill the server process and now everything goes fine. i don't know why but the problem seems associated to the client application used to compile the procedure, because every time the developer tried to compile it using plslqldeveloper 7.14 through "edit-procedure" from his host the behavior was always like I just described before while the compilation of that procedure with other tools or from other hosts runs just fine.
    Actually I haven't been able to find the reason for this, there was no view, among the ones I queried, telling me who was holding the resources, other than the blocked session, and it seems very hard that such a behavior may depend on the client tool used.
    Thanks anywayAlessandro,
    you may want to check the settings of this particular PL/SQL Developer installation. If I remember correctly then there are several settings in PL/SQL Developer related to how the tool connects to the database and compiles objects, e.g. "Safe compilation (using temporary compilation object)", "Background compilation", "Multi-Session" support etc. that might lead to situations where the tool could block itself for instance.
    Regards,
    Randolf
    Oracle related stuff blog:
    http://oracle-randolf.blogspot.com/
    SQLTools++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676/
    http://sourceforge.net/projects/sqlt-pp/

  • Killed sessions

    Hi,
    I kill a session with the commands:
    select username, sid, serial#, status from v$session where username like 'RION%'
    alter system kill session 'sid, serial#'
    and if I give again the first select command at the status column appears KILLED. I want not to have KILLED in the status column.
    Thank you,
    Mihaela

    hi all,
    As u know you are seeing the status of at v$session view as killed, I wanna confirm that this will exists in two senario.
    When a Session is in inactive state and a kill command on that session is issued then the "status" column of v$session will be updated as killed as to indicate/mark as it is killed, and the "server " column will be updated as psuedo. when the user again try to connect to the session user will receive 0ra-00028 error and the entry will be removed from v$session.
    Another senario is that the transaction is at its half way, either in commiting or at the roleback stage for that partucular session then also you can find that the v$table is updated as above.
    more information, go through the documentation, at the Server Process handling section.
    i hope it cleared your confussion,

  • Kill Session in Oracle 10g

    Oracle 10g r2
    I killed a session after fetching the sid and serial from the v$session as under
    select * from v$session where username='SAM';
    alter system kill session '530,7420'
    Now the status showed killed.
    But again after some time one i query the v$session the status turn to inactive.
    Why so?

    Yeah Madrid....
    Thanks for that.. at the developer side.. they did get session killed.
    But actually my doubt here was. that once i killed the session then i go the status as "killed" in the v$session
    but less then a minute when i again query the v$session then i see the status aa inactive. This is what is not clear to me.

  • ALTER SYSTEM KILL SESSION privilege

    Hi All,
    Is there any possibility to use this command from a without having DBA priviileges, what is the privilege to be grantd to the ordinary users to execute ALTER SYSTEM KILL SESSION... statement..
    Thanks in advance

    The procedure proposed by Rusell would be more or less so:
    SQL> create or replace procedure kill_session
      2  ( v_sid number, v_serial number )
      3  as
      4  v_varchar2 varchar2(100);
      5  begin
      6  execute immediate 'ALTER SYSTEM KILL SESSION '''
      7  || v_sid || ',' || v_serial || '''';
      8  end;
      9  /
    Procedure created.
    SQL> select username, sid, serial# from v$session;
    USERNAME                              SID    SERIAL#
                                          147       5078
    SYS                                   148       6161
                                          151       6769
                                          156          1
                                          158          1
                                          159          1
    REPOS_OWNER                           161      14502
                                          163          1
                                          164          1
                                          165          1
                                          166          1
    USERNAME                              SID    SERIAL#
                                          167          1
                                          168          1
                                          169          1
                                          170          1
    15 rows selected.
    SQL>
    SQL> exec kill_session(161,14502);
    PL/SQL procedure successfully completed.
    SQL>Joel Pérez
    http://otn.oracle.com/experts

Maybe you are looking for

  • Dump when run in background

    Hi All, I have a z-report which displays a ALV report. when I run this in background it gets canceled. when i see the log , it has dump and dump is as shown below. A RAISE statement in the program "CL_GUI_CONTROL================CP" raised the excepti

  • A startup class to enable MQ Queues to trigger MDBs in WLS 6.1(sp4)

              Hi,           I am hoping for references to documentation or opinions on the following method           allowing the use of MQ queues to drive MDBs in WLS. The technique involves rebinding           the connection factory in jndi at "weblog

  • Gerring Error -"Could not open command file"

    Hi All, I'm using Business Object Data services XI 4.0 .When I executes the job it given an error -"Could not open command file " so if anyone know the solution then please let me know. Thanks Rajeev kumar SAP-BODI Developer

  • Pasting from numbers?

    I need to paste tables from numbers to pages. everytime i do so, however, the axis, fonts, and all the stuff gets screwed up. With my old PC (ewww!, i know), i would use the "paste special" function and past the table as a picture, thereby preserving

  • Oc4j server

    Hi, I have a problem to run my jsp page.The project was running properly in other machine using the same server(oc4j server).when i run the test jsp page,i got following error message: 500 Internal Server Error OracleJSP: oracle.jsp.parse.JspParseExc