Re: How to kill a session (Script)

From: Geoffrey <g.dufour_at_swing.be>
Date: Tue, 29 Jan 2002 09:39:19 +0100
Message-ID: <3c565eac$0$33510$ba620e4c_at_news.skynet.be>


Hi David,

Thanks for your help.

Here is the error I get :


The following error has occurred:

PROCEDURE MYUSER.TEST2
On line: 3
PLS-00103: Encountered the symbol "IMMEDIATE" when expecting one of the following:

   := . ( _at_ % ;



PROCEDURE test2 IS

BEGIN execute immediate 'ALTER SYSTEM KILL SESSION '2,3'';

END test2;


"David A. Levy" <david.a.levy_at_rogers.com> a écrit dans le message de news: W3j58.4242$liz.3068_at_news2.bloor.is...
> Hi Geoffrey,
>
> I think the problem you are having is that only DML and SELECT SQL
> statements are allowed to be used directly in PL/SQL. So you can do
 INSERT,
> SELECT etc, but not ALTER, CREATE etc. You have to use dynamic SQL. So
 this
> procedure does NOT work:
>
> CREATE OR REPLACE PROCEDURE
> PROCEDURE sample_alter AS
> BEGIN
> alter system enable restricted session;
> END;
>
> whereas this one should (assuming the user owning the procedure has privs
 to
> execute an ALTER SYSTEM in the first place)
>
> PROCEDURE SCOTT.sample_alter IS
> BEGIN
> execute immediate 'alter system enable restricted session';
> END;
>
> If the user does not have the privs you will get messages like these:
>
> ERROR at line 1:
> ORA-01031: insufficient privileges
> ORA-06512: at "SCOTT.SAMPLE_ALTER", line 3
> ORA-06512: at line 1
>
> hope this helps,
> David.
>
>
Received on Tue Jan 29 2002 - 09:39:19 CET

Original text of this message