Re: PL/SQL-Tables and Integer-Indexes

From: Didier LENQUETTE <didier.lenquette_at_steria.fr>
Date: Wed, 05 Jan 2000 18:37:44 GMT
Message-ID: <YbMc4.12$Hs.466_at_nreader2.kpnqwest.net>


Hi Pascal !

>
> declare
> Type TtabWords is Table of Varchar2(50) Index By Binary_Integer;
> tabWords TtabWords ;
> i Integer ;
> begin
> ... fill the elements 1 .. 35 of tabWords
> for i in tabWords.FIRST .. tabWords.LAST loop
> dbms_output.put_line(tabWords(i)) ;
> end loop ;
> end ;
> (Oracle 7.3.4.0.0 on Win NT)
>
> I found it gave me (occasionally) a no_data_found-exception when
> referencing the 17th element. Because the error showed up only
> occasionally, I am not sure about the 17th element. However, after
> replacing the type of i by binary_integer, the error didn't happen any
> more.
>
> Can anybody tell us
> 1) what happened

You have reach the 17th element that doest not exist in your table !

> 2) why the error occured only intermittently
Because you may have deleted a row intermittently !

> 3) why the compiler didn't produce an error nor a warning
Because it is a runtime error !

> I wonder if the rest of the oracle-programming world is aware of this.
Yes ! But it is a normal behaviour !
You should enclose the statement like this begin

     dbms_output.put_line(tabWords(i)) ; exception when no_data_found then

     dbms_output.put_line('Item ' || i || ' does not exist') ; end;

Didier LENQUETTE Received on Wed Jan 05 2000 - 19:37:44 CET

Original text of this message