Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: whenever sqlerror is an unknown statement?

Re: whenever sqlerror is an unknown statement?

From: Mark C. Stock <mcstockX_at_Xenquery>
Date: Wed, 25 Jan 2006 13:19:07 -0500
Message-ID: <3aOdnRmJucqCXErenZ2dnUVZ_sOdnZ2d@comcast.com>

<jjsavage_at_gmail.com> wrote in message
news:1138212843.470506.221480_at_f14g2000cwb.googlegroups.com...
> Thanks! But it doesn't work:
>
> declare x varchar(20);
> begin
> select id into x from pass where id = '1';
> exception
> when others then
> if sqlcode = -942 then
> execute immediate 'create table pass(a char(10));';
> end if;
> end;
>
> Gives ORA-06550: line 4, column 23: PL/SQL: ORA-00942: table or view
> does not exist ORA-06550: line 4, column 1: PL/SQL: SQL Statement
> ignored. So it's not catching any 'others', and it's not creating the
> table (I know because the same thing happens if I run it again).
> What's wrong?
>
> Thanks again,
> John
>

in a pl/sql block you can only trap this if you are using dynamic sql

you are getting a compile time error

you can check ORA-00942 in pre-compiler environments

++ mcs Received on Wed Jan 25 2006 - 12:19:07 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US