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

Home -> Community -> Usenet -> c.d.o.server -> Re: tables with binary_integer in PL/SQL

Re: tables with binary_integer in PL/SQL

From: Jurij Modic <jurij.modic_at_mf.sigov.mail.si>
Date: 1997/01/06
Message-ID: <32D142E4.38B1@mf.sigov.mail.si>#1/1

Kjetil Skotheim wrote:
>
> How can I easily test if an entry in a table exists?
>
> The following does not work:
>
> declare
> type tt is table of number(10) index by binary_integer;
> brb tt;
> begin
> brb(1023):=234;
> if exist brb(1023) then begin
> logg(to_char(brb(1023))); end;
>
> end;
> /
>
> I could catch exceptions, but prefer to avoid that.
>
> Any ideas?

Try using exception handler. Your (modified) example:



declare
  type tt is table of number(10) index by binary_integer;   brb tt;
  n number;
  dummy number;
begin
  n := 1023;
  brb(n):=234;
  select brb(n) into dummy from dual;
  n := 1024;
  select brb(n) into dummy from dual;
exception
  when no_data_found then
    dbms_output.put_line('brb('||to_char(n)||') - No such field in brb');
end;

jure
-- 
 ===============================================================
 ! Jurij Modic                            Republic of Slovenia !
 !  tel: +386 61 178 55 14                Ministry of Finance  !
 !  fax: +386 61  21 45 84                Zupanciceva 3        !
 !  e-mail: jurij.modic_at_mf.sigov.mail.si  Ljubljana 1000       !
 ===============================================================
Received on Mon Jan 06 1997 - 00:00:00 CST

Original text of this message

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