Kill the session Using Pl/sql Script

Hi,
I wrote a PL/SQL Script which kills the Specified Schema name..... the Script Run Successfully i got this output message "PL/SQL procedure successfully completed." But the Problem is in session status the status is in KILLED" state for more than 30 minutes.
Please Advice Why the Session in Killed State for more than 30 minutes and please tell me how to kill the session immediate;
I am Using Oracle DB 11g R1 and OS is Windows 2003 Server R2
My Pl/sql Script
SET SERVEROUTPUT ON;
DECLARE
KILLER1 V$SESSION.SID%TYPE;
KILLER2 V$SESSION.SERIAL#%TYPE;
CURSOR KILL_SESSION IS SELECT SID,SERIAL# FROM V$SESSION WHERE SCHEMANAME='NAME';
BEGIN
OPEN KILL_SESSION;
LOOP
FETCH KILL_SESSION INTO KILLER1,KILLER2;
EXIT WHEN KILL_SESSION%NOTFOUND;
DBMS_OUTPUT.put_line ('ALTER SYSTEM KILL SESSION '''||KILLER1||','||KILLER2||''' IMMEDAITE');
EXECUTE IMMEDIATE 'ALTER SYSTEM KILL SESSION'||chr(39)||KILLER1||','||KILLER2||chr(39);
END LOOP;
IF (KILLER1 > 0)
THEN
EXECUTE IMMEDIATE 'ALTER SYSTEM KILL SESSION'||chr(39)||KILLER1||','||KILLER2||chr(39);
END IF;
CLOSE KILL_SESSION;
END;
Thank You
Shan

Hello,
In fact you may use orakill it's an Oracle utility for Windows so as to Kill the thread corresponding
to the session.
It's equivalent to a kill -9 on Unix.
Please find here a link about the use of orakill:
http://articles.techrepublic.com.com/5100-10878_11-5224960.html
Hope this help.
Best regards,
Jean-Valentin
Edited by: Lubiez Jean-Valentin on Mar 27, 2010 5:17 PM

Similar Messages

  • How can we Kill the session using Maxl

    Hi All,
    iam using EAS(11.1)
    i want to kill the sessions before loading the dimension and data into the cube , if any body connected or workinng on that server cube bcoz
    to avoid cube correptions
    how can i write MAXl for this scenario.???
    If any help,It would be appriciated.
    Thanks

    Hi,
    You can use the following maxl statements
    alter system kill request all;
    Which will kill all requests on the essbase server, also you can use
    alter system logout session all force;
    More information available at :- http://download.oracle.com/docs/cd/E12825_01/epm.111/esb_techref/maxl_altsys.htm
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • Regarding KILLING the session

    Hi..
    How to kill the session from the SQL * Plus ...please tell me anyone
    regards
    Yashavanth

    ALTER SYSTEM command. Refer to the [url http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_2013.htm#i2053602]Oracle® Database SQL Reference guide.
    However...
    1. This needs a SYSDBA priv. End-user and application schemas must NEVER be able to use the ALTER SYSTEM command directly. That will be a very serious and utterly silly security risk. (the type that can get you fired in the corporate world)
    2. Killing sessions is an exception. This should not be the run-of-the-mill thing. Why do you need to kill sessions from SQL*Plus? Are you sure that this is the best response to the problem you have? What is that problem? maybe we can offer better alternatives.

  • Setting and retrieving session using pl/sql

    How to set and retrieve session using pl/sql?Can anyone help me?

    mrs wrote:
    create or replace
    function get_login_details(in_user in VARCHAR2,in_pwd in VARCHAR2,in_cname in VARCHAR2)
    ..snipped..The code should look as follows:
    create or replace function AuthenticateUser( userName varchar2, userPassw varchar2, userGroup varchar2 )
    return integer is
      i integer;
    begin
      --// purpose of the SQL is simply to check if such a row exist -
    --// no data from the row needs to be fetched
      select 1 into i from acl_users_gv
      where user_name = userName
      and password = userPassw
      and entity_group_name = userGroup;
      --// if the SQL succeeded, then the row exists and matches
      --// the authentication details
      return( 0 );
    exception when NO_DATA_FOUND then
      --// SQL failed to find a row - authentication details do
      --// not exist
      return( 1 );
    end;No need to fetch data unnecessarily. No need too check the fetched data when the column values are already checked via the SQL filter condition (predicate).
    No need to return a flag variable as a freely formatted text string containing Successful Login and login failed. That is not a robust design to use a string variable like that. Use boolean for true/false. Or use integer values 0/1.
    This is my function get_login_details.And I need to get this 'o_mesg' in other java file also.Standard PL/SQL call from Java. The SQL string to execute contains an anonymous PL/SQL and needs to use bind variables. E.g.
    begin
      :result := AuthenticateUse( :userName, :userPassw, :userGroup );
    end;
    Can you suggest the right way, how I can get this variable in other pages?That depends on whether there is database session state. If there is, authentication can be done once only via a trusted context, that specifies whether the session is authenticated.
    If this is done from an app server that uses a db session pool and stateless db sessions, the state needs to be kept in the app server.
    Do you understand what stateful versus stateless db sessions are, and what the differences are?

  • Setting session using pl/sql

    How to set and retrieve session using pl/sql?Can anyone help me?

    This is the wrong forum for SQL or PL/SQL questions.
    1. Post your question in the SQL and PL/SQL forum
    https://forums.oracle.com/forums/forum.jspa;jsessionid=8d92100c30d7960321c250bf4adeaa5dcac037eb147c.e34SbxmSbNyKai0Lc3mPbhmSbNaLe0?forumID=75&start=0
    2. Edit this thread and post the link to your new question.
    3. Mark this thread ANSWERED so people will follow up in the other forum.
    When you post your new question provide your 4 digit Oracle version (result of SELECT * FROM V$VERSION). You will also need to explain what you mean by 'set and retrieve' session. A session is created when a logon is successful so 'set' and 'retrieve' only have meaning in terms of trying to set or retrieve session parameters that may be in effect.

  • How to remove the Sessions used in the application

    Hai Techies,,,
    i am using many number of sessions in my application, for example i am using 5 sessions in reports module
    my application is a web based application
    if can't remove the sessions it contains the huge amount of data , my application is going into mess, and the application performance will be decreased..
    Can anybody tell the solution for this Problem
    How to remove the Sessions used in the application
    Hoping a reply
    Thanks & Regards
    Krishna mangamuri

    Hai Gita,
    i am not able to do the session invalidate method bcoz, i am mainatainting the session from login along with the current userid who is login into the system and putting some of the data in session....
    thats session is to be valid upto when i click on logoff link
    except that i have to remove the sessions in my application
    while navigating from one jsp to another i have to remove the sessions, bit somes times that sessions may be used somewhere
    Can u Understand My problem
    session remove method may also helpful to me but some times it will casue some prob to me
    Is there any other Way to remove the sessions in the Application ????
    Thanks & Regards
    Krishna Mangamuri

  • Kill the Session in Apex

    Hi, How to kill the session in apex 4.1.
    We are running Application Security scan. When we run the scan we are getting error as Session Identifier not updated issue is coming.
    For that resolutions are Always generate a new session to which the user will log in if successfully authenticated. Prevent user ability to manipulate session ID.
    Do not accept session IDs provided by the user's browser at login.
    Is pagesentry function any helpful to create our own session?
    Basically what i want means when we logout the session we have to destroy the session and when we login we have to create new session.
    Thanks in advance

    Hi, How to kill the session in apex 4.1.
    We are running Application Security scan. When we run the scan we are getting error as Session Identifier not updated issue is coming.
    For that resolutions are Always generate a new session to which the user will log in if successfully authenticated. Prevent user ability to manipulate session ID.
    Do not accept session IDs provided by the user's browser at login.
    Is pagesentry function any helpful to create our own session?
    Basically what i want means when we logout the session we have to destroy the session and when we login we have to create new session.
    Thanks in advance

  • Killing the session in SAP

    HI,
       I need to kill the session , how to proceed .Please help me.
    Thaks
    Raghavendra

    Always activate the form before logging off from SAP.
    Next thing, if you still see the same problem check SM12 if there is any user trying to do with the form( but I am not sure this would be the case, as it is not locking of some table or something. Only thing is you might able to see the form in display mode atleast. Is that correct??)
    Check with Basis guys about the problem and see if they could help you out on this problem

  • Using a SQL script to make the Status of a Concurrent Request 'WARNING'

    We have a SQL script based Concurrent Program. How to show the STATUS as 'WARNING' in the SRS screen based on a user defined Flag.
    What we are trying is similar to RETCODE = 1 in any standard package OUT variable, but just by using SQL or PL/SQL.
    Please let me know if more details are needed to explain the problem / scenario.

    Guys, found the solution...
    1) For completing with a WARNING and yellow bar:
    v_dummy :=FND_CONCURRENT.set_completion_status('WARNING','User message. Job completed.');
    2) For completing with an ERROR and red bar:
    v_dummy := FND_CONCURRENT.set_completion_status('ERROR',' User message. Job aborted.');

  • Search for tablenames in the database using native sql query script

    How do i search for the names of the tables in the database using select statement? I do not know the names of the tables but I know the name of the database and i do not have the sys priviliges.
    thanks
    SS

    SELECT owner, table_name
    FROM all_tables;

  • How to kill the session after the user exit the ADF application

    Dear all
    I have a problem
    The problem is the session still exist after the user close the application and the browser. I want to kill all sessions that is not active.
    This is my test scenario:
    1- I open IE and run my ADF application that is deployed on weblogic. http://192.168.100.17:7001/myapp/faces/login
    2- At the same time I issue this SQL command to view the sessions for user 'ADFUSER' - the "ADFUSER" is the schema user.
    SELECT USERNAME,STATUS FROM v$session
    WHERE USERNAME = 'ADFUSER';QUERY RESULT IS
    USERNAME                       MODULE                                           STATUS
    ADFUSER                         JDBC Thin Client                                 INACTIVE3- Now the user close the browser
    4- Run the SQL again and I notice that the session still exist
    SELECT USERNAME,STATUS FROM v$session
    WHERE USERNAME = 'ADFUSER'RESULT:
    USERNAME                       MODULE                                           STATUS
    ADFUSER                        JDBC Thin Client                                 INACTIVE5- now the user open the URL again http://192.168.100.17:7001/myapp/faces/login
    6-Run the SQL again , and I notice that the old session still exists and a new session created too.
    SELECT USERNAME,STATUS FROM v$session
    WHERE USERNAME = 'ADFUSER'RESULT:
    USERNAME                       MODULE                                           STATUS
    ADFUSER                        JDBC Thin Client                                 INACTIVE
    ADFUSER                        JDBC Thin Client                                 INACTIVE
    2 rows selected.and every time I login to the application , a new session is open and the old session still exist
    I do not know why this happens
    I want to kill old session when the user close the application.
    These sessions are cleared only when i restart the weblogic domain.
    here is some information about my development environment:
    Jdeveloper 11.1.2.3
    WebLogic Server Version: 10.3.5.0
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    thanks in advance

    Hi,
    for performance reasons you should not use dedicated user connections to the database. Instead you use JDBC data sources (default in JDeveloper for ADF BC) that you can configure the database connection pooling for. This means that your v$session will always show a set of active session, which however are shared among users. Assuming you use ADF BC, this is what happens
    - A user requests a data bound page
    - The ADF BC checks out an AM and connects to the database using one of the database connections in the pool
    ... user work here ...
    - user exits application
    - ADF BC returns AM to pool and passivates pending user state (if application is left with dirty transaction)
    - Database connection is available in pool as soon as AM released
    This also happens between requests. Long story cut short: v$session doesn't give you a true picture
    Frank

  • Kill DBA session feature in SQL Developer

    Hi All,
    Like in TOAD , we have a Kill/DBA session option is on toolbar and we can easily trace down the sessions running as well as SID and serial number ..... Do We have similar feature on SQL Developer ?
    Currently my SQL Developer version is 1.0.0.14.67 and Build Main 14.67

    it's in sqldev 1.1 (in reports/database administration/sessions/sessions)

  • Using an SQL Script file to create database in Java? (monkeyDB.sql)

    Hello!
    I am a writing an SQL Script so that I can re-create my database on another server (im using my laptop to test it on first though).
    I'm connecting to mySQL server using JDBC which works fine, but I was wondering
    how can I run an entire script file, say myScript.sql from within a Java class??
    (an SQL Script is simply a file containing the regular SQL commands and expressions that you might enter at an sql command line prompt)
    example of an SQL Scritp: monkeyDB.sql>>
    //#create new db
    CREATE DATABASE sample_db;
    //#set active db
    USE sample_db;
    //#set table paramaters
    CREATE TABLE monkeys
    (name CHAR(20),
      age INT UNSIGNED,
      sex ENUM('M','F')
    //#create standard monkeys
    INSERT INTO monkeys(name,age,sex) VALUES("Sammy",10,"M");
    INSERT INTO monkeys(name,age,sex) VALUES("Muncht",12,"M");
    INSERT INTO monkeys(name,age,sex) VALUES("Jill",8,"F");
    //#get recordset
    SELECT * FROM monkeys WHERE age < 50;Thanks for your help!

    thanks. :-)
    I thought about that too but I didnt want to hard wire it into the code.
    I guess it isnt possible to output the script file using some command from the sql library..?

  • Getting the schema using Oracle SQL Developer 1.5.1

    I need to generate a report in CSV/XLS format using Oracle SQL Developer 1.5.1 to get the schema details
    in the below format.
    Table Name: XXXXXXXXX
    Table Space Name: XXXXXXXXXXXXXXX
    Structure :
    Field Name Data Type Size
    Xxxxxxxx xxxxxx xxxxx
    Xxxxxxxx xxxxxx xxxxx
    Xxxxxxxx xxxxxx xxxxx
    Xxxxxxxx xxxxxx xxxxx
    Field level constraint:
    Xxxxxxxxxxxxxxxxxx
    Table Level Constraint:
    Xxxxxxxxxxxxxxxxxx
    Indexes:
    Index Name Column Name(s) Table space name
    Xxxxxxxx xxxxxxxxx xxxxxxxxxxxx
    Xxxxxxxx xxxxxxxxx xxxxxxxxxxxx
    Xxxxxxxx xxxxxxxxx xxxxxxxxxxxx
    Sequence Number:
    Xxxxxxxxxxxxxxxx
    Triggers:
    Xxxxxxxxxxxxxxxxxx
    I am using a query to do that, but I cannot run more than one queries in the Create Report Dialog.
    I went to the Menu->View->Reports. In that, I chose User Defined Reports, created a new folder called Schema Detail and in that a report named Schema Detail. I right click on that report, choose Edit option, Create Report Dialog opens.
    In the Create Report Dialog, I chose the option Script for Value of Style.
    In the SQL column I enter a query "select * from table_names". But, if I enter another query after that, it does not run and reports an error "SQL Error: ORA-00933: SQL command not properly ended
    00933. 00000 - SQL command not properly ended" Cause:    Action: "
    I end the first query with a semi colon, but it does not work.
    The queries run fine in a SQL Worksheet. There, I can terminate the first query with a semi colon and enter the second query. Then, I run both of them together so that result-set of second query appears after the second.
    Am I doing something wrong? Can someone please advise on how to get the information I need?
    Thanks a lot.

    You can do it in SQL Worksheet because you are running a script. You could run the script in SQL*Plus, and even start it from a bat/cmd file.
    Or if you want this as a User Defined Report, you might make it a PL/SQL style report. Here, all output is done through DBMS_OUTPUT.PUT or DBMS_OUTPUT.PUT_LINE. You can output HTML tags or plain text. I have an example in my paper for ODTUG Kaleidoscope 2009.

  • How to practise on the examples used in SQL Expert book

    I need to study for the oracle sql expert exam and I am using the book SQL Expert exam guide by Steve O' Hearn.
    Can someone please suggest how to practise on the examples of this book ?

    dfcii wrote:
    Good morning,
    IMHO, I would have suggested that one build the schemas and tables they need from scratch. If one is to be an Oracle Certified Expert in SQL, one should be able to do perform those tasks quickly and accurately. I realize that in larger shops, those tasks might be/are deligated to the DBA team, but having worked in both small and large shops, I believe that being an "expert" should include more than the ability to copy source code and run somoene else's sql scripts.
    Thanks,
    Don.
    Edited by: dfcii on Jan 9, 2012 6:57 AMI think both viewpoints are valid.
    - In some ways one does not want to spend time dealing with books misprints and typos when really to be able to do the SQL expert exam one should be on top of anyway.
    - In other sense getting ones one test data togther is useful.
    ..... I possibly remember badly .... but i seem to miss where the scripts mysef (at least initially) and spent some wasted time pumping in a fair bit of data for the earlier examples.

Maybe you are looking for

  • How can I set up albums within photostream or flickr?

    I set up photostream on iphoto (thanks for those hints!). Now, I dragged an album of photos into photostream. But I noticed that all the photos are in one long list. Can I create albums within photostream? So that I can then have a lot of photos in t

  • CS4 Bridge  Web Gallery

    Is there any galleries that you can add audio???  In CS3 you could add audio but I do not see how to do in CS4.

  • Problem installing Oracle9i Database

    When i installed the software, it got through to almost 50%, but then the installer screen suddenly disappeared off the screen and my pc shut-down and restart automatically. I don't know what was the problem because there wasn't even an error message

  • Is it possible to insert a playlist in the search field

    hi ! I want to purchase a playlist from spotify is it possible to paste this playlist in the search field, or do i have to paste one and one tune to get them all?

  • How can I use the scroll wheel to move page by page

    I have Adobe Acrobat 8 and I would like to be able to use the scroll wheel in my mouse to move page by page instead of the page icons in the tool bar.  I recently had my computer updated from Windows XP to Windows 7 and I used to be able to do that i