Skip to Main Content
  • Questions
  • PL/SQL-Collections: EXISTS for Associative Array

Breadcrumb

Question and Answer

Tom Kyte

Thanks for the question, Peyman.

Asked: November 28, 2014 - 10:49 am UTC

Last updated: November 28, 2014 - 11:22 pm UTC

Version: 11.2.0.2.0 -

Viewed 10K+ times! This question is

You Asked

Hi Tom,


In the Documentation is written that:
"You cannot use EXISTS if collection is an associative array"

But I have tried this and it works very fine. Please check this Siite which uses an associative array indexed by varchar2:

http://www.oracle-developer.net/display.php?id=428

I would be very garateful for your answer as I want to be sure that my procedure from six months ago was written correctly.

Thanks

and Tom said...

When you find a discrepancy like that, it would be best to boil the sample down to the very essence of the issue AND link to the doc.. something like:


doc https://docs.oracle.com/database/121/LNPLS/collection_method.htm#LNPLS01306 says "You cannot use EXISTS if collection is an associative array", but that is not true as evidenced by:

ops$tkyte%ORA11GR2> declare
  2     type aarray is table of varchar2(20) index by varchar2(1);
  3     l_data aarray;
  4  begin
  5          l_data('A') := 'hello world';
  6  
  7          if ( l_data.exists('A') )
  8          then
  9                  dbms_output.put_line( 'it exists' );
 10          end if;
 11  end;
 12  /
it exists

PL/SQL procedure successfully completed.




I've notified the doc writers about this - looks like a doc bug, it was probably an unimplemented feature back in the past that got implemented but the doc was never updated.

Is this answer out of date? If it is, please let us know via a Comment

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library