niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Databases » Oracle
Associative array as inbound parameter
Post new topic   Reply to topic Page 1 of 1 [2 Posts] View previous topic :: View next topic
Author Message
sybrandb
*nix forums beginner


Joined: 13 Jul 2006
Posts: 22

PostPosted: Thu Jul 20, 2006 8:18 am    Post subject: Re: Associative array as inbound parameter Reply with quote

ds_lewis@hotmail.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
Back to top
ds_lewis@hotmail.com
*nix forums beginner


Joined: 01 Jun 2006
Posts: 2

PostPosted: Thu Jul 20, 2006 1:13 am    Post subject: Associative array as inbound parameter Reply with 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
)
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [2 Posts] View previous topic :: View next topic
The time now is Thu Dec 04, 2008 3:33 am | All times are GMT
navigation Forum index » Databases » Oracle
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Arbitrary function with parameter darknails@gmail.com C++ 2 Fri Jul 21, 2006 9:58 am
No new posts Trouble Declaring 3D Array in Header File free2klim C++ 1 Fri Jul 21, 2006 4:07 am
No new posts determine pointer to point to array or single item during... yancheng.cheok@gmail.com C++ 5 Fri Jul 21, 2006 1:17 am
No new posts FAQ 4.41 How can I remove duplicate elements from a list ... PerlFAQ Server Perl 0 Fri Jul 21, 2006 1:03 am
No new posts how to convert byte array into integer msosno01@gmail.com C++ 3 Thu Jul 20, 2006 9:07 pm

Credit Cards | Fast Loans | Nancy Ajram | Mortgages | Montana Music
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1665s ][ Queries: 20 (0.0641s) ][ GZIP on - Debug on ]