Creating associative arrays [message #343771] |
Thu, 28 August 2008 02:02  |
homersimpson
Messages: 3 Registered: August 2008
|
Junior Member |
|
|
Hi,
I'm using PL/SQL.
I would like to create data type I call hash, which is an associative array with varchar2(30) keys:
-- This is my hash table, having strings as keys and very long string as values
CREATE OR REPLACE TYPE hash IS TABLE OF VARCHAR2(1000) INDEX BY VARCHAR2(30);
I cannot create this array outside of a package scope, as I get the following error:
Quote: |
PLS-00355: use of pl/sql table not allowed in this context
|
Only if I remove the INDEX BY... code from the declaration of the hash, can I pass compilation without an error. This is not good for me, as I would like to use strings as keys.
My goal is to use this hash as a type for a data-member of another object - how can I achieve that?
Thanks.
|
|
|
|
Re: Creating associative arrays [message #343797 is a reply to message #343774] |
Thu, 28 August 2008 03:37   |
homersimpson
Messages: 3 Registered: August 2008
|
Junior Member |
|
|
Thanks for the quick response Michel!
I would like to create an object (let's call it foo) that uses the hash type for a data member - let's call it my_hash. I have a function bar that adds items to my_hash and a function bar2 that reads the contents of my_hash.
How can I do that? I tried to define the hash type as part of creating the foo object, but it failed to compile as well.
Thanks again.
|
|
|
|
|
|
|