Click to See Complete Forum and Search --> : populating a varray fails


sshravan
08-25-2004, 11:29 AM
I am populating a varray l_varray_txn with the txn_id's and pass it to the object l_per_chg_obj with in a cursor, which gets the txn id's. But only the last txn id fetched is being passed on to the object.

Ex. 1st txn_id 45858
2nd txn_id 48585
3rd txn_id 48578

The l_per_chg_obj only contains the 3rd txn id - 48578 and what we want is that it should contain all the three txn_id's. I have tried doing a l_varray_txn(l_varray_txn.last) also and it errors out saying subscript out of range.

I am giving the code below. and the part above declare is the declaration of the various objects and varray's.


========================================================================================
adt_fabs_txn_hist_type as object( txn_id number, prev_txn_id number)

adt_fabs_txn_hist_varray as varray(1000) of adt_fabs_txn_hist_type

l_per_chg_obj := adt_fabs_per_chg_type(
cur_rate_per.oab_person_id,
l_chr_client_id,
l_cycle_run_id,
l_varray_txn_cd,
l_varray_txn)

declare
l_varray_txn adt_fabs_txn_hist_varray := adt_fabs_txn_hist_varray();
l_txn_hist adt_fabs_txn_hist_type;
l_varray_txn_cd adt_fabs_txn_ty_cd_varray := adt_fabs_txn_ty_cd_varray();

l_per_chg_obj adt_fabs_per_chg_type := adt_fabs_per_chg_type(NULL, NULL, NULL, l_varray_txn_cd, l_varray_txn);

begin

FOR cur_rate_per IN c_get_rates_per

LOOP
l_person_id := cur_rate_per.oab_person_id;

FOR cur_rate IN c_get_rates
LOOP

l_txn_hist := adt_fabs_txn_hist_type(cur_rate.fabs_txn_id,-1);
l_varray_txn.extend;
l_varray_txn:= adt_fabs_txn_hist_varray(l_txn_hist);

l_varray_txn_cd := adt_fabs_txn_ty_cd_varray('NMI');

END LOOP;

l_per_chg_obj := adt_fabs_per_chg_type
(
cur_rate_per.oab_person_id,
l_chr_client_id,
l_cycle_run_id,
l_varray_txn_cd,
l_varray_txn
);

DBMS_OUTPUT.PUT_LINE('Calling enqueue API for: ');
DBMS_OUTPUT.PUT_LINE(' '||l_per_chg_obj.person_id||' '||l_per_chg_obj.client_id||' '||l_per_chg_obj.run_id);

fabs_oraq_pkg.fabs_per_chg_router(l_cycle_run_id,l_chr_client_cd,l_per_chg_obj);

END LOOP;