To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here

HOME News MS SQL Oracle DB2 Access MySQL PHP Scripts Books Links DBA Talk


Go Back   Database Journal Forums > Miscellaneous > General Database Discussions

General Database Discussions Discuss any database topic not covered in any other forum on this site

Reply Post New Thread
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 07-25-2003, 04:12 AM
kubeld kubeld is offline
Junior Member
 
Join Date: Mar 2003
Location: UK
Posts: 2
Question Initialisation of VARRAY of RECORDs

How do I initialise a VARRAY of RECORDS using literals?

If I define the record using:

TYPE t_myrecord IS RECORD (
field1 varchar2(5),
field2 varchar2(5),
field3 varchar2(5) );

and then define the array type:

TYPE t_myarray IS VARRAY(20) OF
t_myrecord;

and then define and initialise the array using:

a_myarray t_myarray := t_myarray();

where all of the above is listed between the DECLARE and first BEGIN statements, any attempt to assign values to the array within the BEGIN block gives either a 'VARRAY not initialised error' or 'wrong number or type of parameter into t_myarray' when using syntax like:

a_myarray(1) := t_myarray('a', 'b', 'c');

Also, the following syntax complains that t_myrecord is not defined:

a_myarray := t_myarray(
t_myrecord('a', 'b', 'c'),
t_myrecord('d', 'e', 'f'),
t_myrecord('g', 'h', 'i'));

Even if I use this last syntax in the DECLARE block.

Does anyone have any working examples?

I'm using Oracle 9.2.3.0 on an AIX 5L platform.


Reply With Quote
  #2  
Old 07-25-2003, 06:27 AM
YuckFou YuckFou is offline
Registered User
 
Join Date: Mar 2003
Location: London
Posts: 151
Maybe you have to declare another variable like a_myrecord...

DECLARE

TYPE t_myrecord IS RECORD ( field1 varchar2(5), field2 varchar2(5), field3 varchar2(5) );
TYPE t_myarray IS VARRAY(20) OF t_myrecord;
a_myrecord t_myrecord;
a_myarray t_myarray := t_myarray();

BEGIN
a_myrecord.field1 := 'a';
a_myrecord.field2 := 'b';
a_myrecord.field3 := 'c';
a_myarray.extend(19);
a_myarray(1) := a_myrecord;
a_myarray(2) := a_myrecord;
-- ...
a_myarray.extend(1); -- plus last extend of max 20
a_myarray(20) := a_myrecord;
END;
/
Reply With Quote
Reply Post New Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 03:05 AM.


DatabaseJournal Recent Articles


 » Preparing To Upgrade Access Tables to SQL ...

 » Microsoft Windows PowerShell and SQL Serve...

 » New MySQL Enterprise with Query Analyzer B...

 » Quest Software Strengthens Committment to ...

 » Oracle Unveils New Event-Driven Middleware...

Search Database Journal:
 





Acceptable Use Policy

JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers

Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.