dbTalk Databases Forums  

Associative array as inbound parameter

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss Associative array as inbound parameter in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
AT
 
Posts: n/a

Default Associative array as inbound parameter - 07-19-2006 , 08:13 PM






I really need some help. I am trying to write a procedure with one
inbound parameter as associative array and return a reference cursor.
I'm passing in a list of record ID's that I need to use to select the
rows returned in the cursor.

I believe I have everything working except that the procedure won't
compile when try to access the values in the associative array from
within the procedure. What am I doing wrong? Isn't it possible to use
the values from an associative in a select statement?

CREATE OR REPLACE PACKAGE Array_Package_Test
AS
TYPE t_cursor
IS REF CURSOR
RETURN ENGINE_OIL%ROWTYPE;

TYPE number_array IS TABLE OF NUMBER
INDEX BY BINARY_INTEGER;

PROCEDURE array_procedure_test (
enginetimes_parm IN number_array
,out_cursor OUT t_cursor
);
END
;
/

CREATE OR REPLACE PACKAGE BODY Array_Package_Test
AS
PROCEDURE array_procedure_test (
enginetimes_parm IN number_array,
out_cursor OUT t_cursor
)
IS
BEGIN
OPEN out_cursor FOR

SELECT *
FROM ENGINE_OIL
WHERE engine_timeid IN (SELECT * FROM
TABLE(enginetimes_parm));

-- This doesn't work either - but why?
--SELECT * FROM TABLE(enginetimes_parm);


END array_procedure_test;
END;
/


** Here is the ddl for the engine_oil table.

CREATE TABLE ENGINE_OIL
(
QUARTS NUMBER(10,2) NOT NULL,
ENGINENUMBER NUMBER NOT NULL,
AIRCRAFTNUMBER NUMBER NOT NULL,
ENGINEDATETIME DATE NOT NULL,
ENGINE_TIMEID NUMBER NOT NULL
)


Reply With Quote
  #2  
Old   
sybrandb
 
Posts: n/a

Default Re: Associative array as inbound parameter - 07-20-2006 , 03:18 AM







ds_lewis (AT) hotmail (DOT) com wrote:
Quote:
I really need some help. I am trying to write a procedure with one
inbound parameter as associative array and return a reference cursor.
I'm passing in a list of record ID's that I need to use to select the
rows returned in the cursor.

I believe I have everything working except that the procedure won't
compile when try to access the values in the associative array from
within the procedure. What am I doing wrong? Isn't it possible to use
the values from an associative in a select statement?

CREATE OR REPLACE PACKAGE Array_Package_Test
AS
TYPE t_cursor
IS REF CURSOR
RETURN ENGINE_OIL%ROWTYPE;

TYPE number_array IS TABLE OF NUMBER
INDEX BY BINARY_INTEGER;

PROCEDURE array_procedure_test (
enginetimes_parm IN number_array
,out_cursor OUT t_cursor
);
END
;
/

CREATE OR REPLACE PACKAGE BODY Array_Package_Test
AS
PROCEDURE array_procedure_test (
enginetimes_parm IN number_array,
out_cursor OUT t_cursor
)
IS
BEGIN
OPEN out_cursor FOR

SELECT *
FROM ENGINE_OIL
WHERE engine_timeid IN (SELECT * FROM
TABLE(enginetimes_parm));

-- This doesn't work either - but why?
--SELECT * FROM TABLE(enginetimes_parm);


END array_procedure_test;
END;
/


** Here is the ddl for the engine_oil table.

CREATE TABLE ENGINE_OIL
(
QUARTS NUMBER(10,2) NOT NULL,
ENGINENUMBER NUMBER NOT NULL,
AIRCRAFTNUMBER NUMBER NOT NULL,
ENGINEDATETIME DATE NOT NULL,
ENGINE_TIMEID NUMBER NOT NULL
)

IIRC the CAST operator is missing.
Tom Kyte has similar examples on http://asktom.oracle.com
Search for 'dynamic in list'

Hth

--
Sybrand Bakker
Senior Oracle DBA



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.