Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: using an Hashtable in a Stored Procedure

Re: using an Hashtable in a Stored Procedure

From: Lothar Armbrüster <lothar.armbruester_at_t-online.de>
Date: 10 May 2007 17:58:30 +0200
Message-ID: <874pmkoel5.fsf@prometeus.none.local>


Laura <f.marchioni_at_pride.it> writes:

> Hi all !
> I have to write a little Stored Procedure which collects Varchars from
> a sessionId and stores them in an Array. (One array for every
> sessionId)
> For example in Java it would be like this:
>
> Hashtable hash = new Hashtable();
>
> public addToHash(String sessionId,String value) {
> hash.put(sessionId,value);
>
> }
>
> Is it possible to do the same in PL/SQL ? or do I have to write it in
> Java and load it in Oracle ?
> Thanks
> Laura
>

Hello Laura,

you could try something like this:

subtype tvalue is varchar2(1000);
type thash is table of tvalue index by varchar2; hashtab thash;

procedure addtohash(sessionid in varchar2, value in varchar2) is begin
  hashtab(sessionid) := value;
end addtohash;

For this to work, you need at least Oracle 9.2. Since I'm writing this from memory, the syntax may need slight corrections.

Hope that helps,
Lothar

-- 
Lothar Armbrüster  | lothar.armbruester_at_t-online.de
Hauptstr. 26       |
65346 Eltville     |
Received on Thu May 10 2007 - 10:58:30 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US