Brief comparison between lookup on a varchar2 key
via an index by binary_integer table
and via an index by varchar2 table
Without the associative array, you need to code some hashing by hand...
...
type my_lookups_t is table of t.val%type index by binary_integer;
my_lookups my_lookups_t;
my_val t.val%type;
hash_value binary_integer;
...
begin
for j in ( select idx, val from t )
loop
hash_value :=
Dbms_Utility.Get_Hash_Value (
name => j.idx,
base => 1000,
hash_size => 2048 );
my_lookups ( hash_value ) := j.val;
end loop;
...
hash_value :=
Dbms_Utility.Get_Hash_Value (
name => 'my current index of interest',
base => 1000,
hash_size => 2048 );
my_val := my_lookups ( hash_value );
...
This fragment can now be simplified thus...
...
type my_lookups_t is table of t.val%type index by varchar2(2000);
my_lookups my_lookups_t;
my_val t.val%type;
...
begin
for j in ( select idx, val from t )
loop
my_lookups ( j.idx ) := j.val;
end loop;
...
my_val := my_lookups ( 'my current index of interest' );
...
Not only is the coding simpler, it's more efficient.