1

I have the following code:

DECLARE
 TYPE rt_someDetails IS RECORD(
    deny_discount           VARCHAR2(4) DEFAULT 'NO');
 TYPE someDetails_va IS VARRAY(2) OF rt_someDetails;

 l_someDetails_va someDetails_va;
 l_rt_someDetails rt_someDetails;
BEGIN
 l_someDetails_va := someDetails_va();
 l_someDetails_va.EXTEND;

 -- when in varray, the default value doesn't show up
 dbms_output.put_line('From array:: ' || l_someDetails_va(1).deny_discount);

 -- However, when outside of varray, it works properly
 dbms_output.put_line('Directly from record var:: ' || l_rt_someDetails.deny_discount);
END;

Why doesn't the default value of deny_discount show up when read from the record in varray?

Nick Krasnov
  • 26,886
  • 6
  • 61
  • 78
Robotronx
  • 1,728
  • 2
  • 21
  • 43
  • 2
    extending doesn't populate the array, it simply allocates space for future inserts – tbone Oct 17 '13 at 13:09
  • 1
    So I should create a record, insert it into the varray and THEN try to access the field. Answer the question so I can accept your answer. – Robotronx Oct 17 '13 at 13:12

1 Answers1

1

Extending doesn't populate the array per say, it simply allocates space for future inserts (think NULL elements)

Try creating a record and inserting into the array. Simply extending won't show anything.

tbone
  • 15,107
  • 3
  • 33
  • 40