| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.misc -> Re: PL/SQL exceptions for missing table?
begin
select 'x'
from my_table;
exception
when others then
if sqlcode = -942
then
<table does not exist code>
else
raise;
end if;
or a better solution, if you have a well-organized application.
have a package header that defines exceptions, say g_exception
create or replace package g_exception as
e_ora_invalid_table exception;
pragma exception_init ( e_ora_invalid_table, -942 );
end;
/
begin
select 'x'
from my_table;
exception
when g_exception.e_ora_invalid_table then
<table does not exist code>
end;
My preference will be the second method.
Greg Ferguson <rtmd30_at_email.sps.mot.com> wrote in article
<rtmd30-0405981558340001_at_pangaea.sps.mot.com>...
> Hi,
>
> I looked in the Oracle book, but didn't see an exception that'd be raised
> if I tried to do a select...into with a non-existing table.
>
> I'm trying to handle a case where my code is first run, and its private
> table hasn't been initialized.
>
> Is there a way to handle this condition?
>
> Thanks,
>
> Greg
>
Received on Tue May 05 1998 - 16:58:28 CDT
![]() |
![]() |