?
Solved

FORMS--- Populate a VARRAY

Posted on 2006-11-30
1
Medium Priority
?
1,021 Views
Last Modified: 2008-02-01
How do I move/populate a VARRAY from a form?

This is my Varray , definied in the form:
TYPE detail_record is record (
   alloc_id    number,
  cust_id     number);
Type CUST_ARRAY is varray(20) of DETAIL_RECORD;
CUST_FERC  CUST_ARRAY.

This is my code to populate the varray:
if :form_cust_id1 >0 then
   cust_ferc(1).cust_id        := :form_CUST_ID1;
   cust_ferc(1).alloc_id       := :form_alloc_ID1;
end if;

if :form_cust_id2 >0 then
   cust_ferc(2).cust_id        := :form_CUST_ID2;
   cust_ferc(2).alloc_id       := :form_alloc_ID2;
end if;

is this the correct way? beacuse I also get an ORA-06531 error which implies that teh array wa not populated.



   
0
Comment
Question by:joekeri
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 28

Accepted Solution

by:
Naveen Kumar earned 150 total points
ID: 18051409
CUST_FERC  CUST_ARRAY := cust_array(); -- to initialize with non null but empty by using the constructor;

say cust_ferc.extend;

then say something like cust_ferc(1).cust_id := :form_cust_id2;

similarly say extend again and then go ahead and use the second element.

If u dont want to use extend then do something like this after the begin statement

cust_ferc := cust_array((1,1),(2,2)); -- this will create 2 elements with the constructor.

For more information refer to online oracle pl/sql documentation which has good examples of sample code of varrays , nested tables, associative arrays etc.

Thanks
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question