Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Check if a value is in an associative array?

YourNameHereAug 9 2012 — edited Aug 9 2012
Hi,
I am writing a process to plug into an existing infrstructure. I have an associative array of data (which I cannot change the definition of) that is defined as:
type vc_arr2 is table of varchar2(32767) index by binary_integer;

An example set of data might be:
Key   Text
1 => Apple
2 => Banana
3 => Pear
4 => Plum
5 => Grape
etc etc
Now I need to be able to see whethe a particular text value appears in the values, ie "Is 'Banana' in the array?". Now obviously I could do this by writing a procedure to loop over all the elements sequentially however is there something built in to do this? There is the obvious the overhead of (potentially) looping through every element for each item I am searching for - I am hoping there is something built in which in more efficient (ie, "indexes" values or something like that).
As far as I am aware, ARRAY.EXISTS() works on the key and not the value, and MEMBER OF cannot be used with associative arrays.
I am not interested in what the key is for a given value (and I realise there might be more than one key mapping to a given value), all I am interested in is just whether the item exists in the array.

Any help or sugestions would be greatly appreciated!
This post has been answered by BluShadow on Aug 9 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 6 2012
Added on Aug 9 2012
7 comments
4,637 views