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: PL/SQL exceptions for missing table?

Re: PL/SQL exceptions for missing table?

From: Saad Ahmad <saad.ahmad_at_mchugh.com>
Date: 5 May 1998 21:58:28 GMT
Message-ID: <01bd7870$f2e053e0$2207030a@sahmad-pc.mfa.com>


begin

   select 'x'
   from my_table;
exception

   when others then

      if sqlcode = -942
      then
         <table does not exist code>
      else
         raise;
      end if;

end;

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

Original text of this message

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