Re: get the sid,serial# of my connection?

From: Mark D Powell <Mark.Powell_at_eds.com>
Date: Wed, 24 Dec 2008 08:40:25 -0800 (PST)
Message-ID: <52f525d3-686f-40ae-bbf1-a6cdfbb1d632@u18g2000pro.googlegroups.com>


On Dec 24, 3:42�am, m..._at_pixar.com wrote:
> Michel Cadot <micadot{at}altern{dot}org> wrote:
> > "Mark D Powell" <Mark.Pow..._at_eds.com> a ?crit dans le message de news:
> >> Hey, I learned something new. �thanks Laurenz.
> > So do I
>
> Thanks all... here's my results which are working great.
>
> 1. a shell script to kill a connection:
>
> � � � � #!/bin/sh
> � � � � # kill a specified oracle session
>
> � � � � sid=$1; ser=$2; inst=$3
> � � � � echo -n sys password:
> � � � � stty -echo; read pass; stty echo
> � � � � echo "alter system kill session '$sid,$ser';"|
> � � � � � � �sqlplus -SL sys/$pass@$inst as sysdba
>
> 2. a local function (this in python) to generate a call to this script.
> � �I call this at the beginning of my test program and print the
> � �string so I can cut and paste.
>
> � � � � def killstring(curs):
> � � � � � � """return a string that will kill this db connection"""
> � � � � � � curs.execute("""SELECT dbms_debug_jdwp.current_session_id,
> � � � � � � � � � � � � � � � � � �dbms_debug_jdwp.current_session_serial,
> � � � � � � � � � � � � � � � � � �sys_context('USERENV', 'INSTANCE_NAME')
> � � � � � � � � � � � � � � FROM dual""")
> � � � � � � (sid,serial,instance)=curs.fetchone()
> � � � � � � s="oracle-killsession %s %s %s"%(sid,serial,instance)
> � � � � � � return s
>
> 3. and a sample invocation
>
> � � � � ohm ~/tst$ oracle-killsession 98 45809 tmpltest2
> � � � � sys password:
> � � � � System altered.
>
> 4. and from my client... hooray!!!
>
> � � � � cx_Oracle.DatabaseError: ORA-00028: your session has been killed
>
> Share and enjoy!
> Mark
>
> --
> Mark Harrison
> Pixar Animation Studios

Why not have the routine issue the kill via execute immediate rather than have to cut and paste?

HTH -- Mark D Powell -- Received on Wed Dec 24 2008 - 10:40:25 CST

Original text of this message