Domanda

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?

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top