Better is
Gh, November 13, 2017 - 8:55 am UTC
If your collections are db defined objects your can use the TABLE keyword and do your inserts as sql oneshot. E.g. insert into t
Select colunm value from TABLE(..cast as your type) including a where clause .
Neha Dhingra, November 14, 2017 - 2:46 pm UTC
I changed my code based on the example you gave me, but now its NULL issue. can you suggest me an approach,
TYPE rowlist IS TABLE OF TEMPTBL_NUMBER_SEARCH%rowtype INDEX BY pls_integer;
NUM_COLUMN rowlist;
VAR_COLUMN rowlist;
TYPEDATA rowlist;
BEGIN
select NUM_COLUMN, VAR_COLUMN, TYPE bulk collect into NUM_COLUMN from TEMPTBL_NUMBER_SEARCH;
FOR I in 1 .. NUM_COLUMN.count LOOP
IF(P_Locations(I) !='0') OR (P_WorkCenters(I) !='0') OR (P_KeyRingIds(I) !='0') OR (P_Routes(I) !='0') THEN
VAR_COLUMN(VAR_COLUMN.count+1):=NUM_COLUMN(I);
TYPEDATA(TYPEDATA.count+1):=NUM_COLUMN(I);
ELSE
NUM_COLUMN := I;
END IF;
END LOOP;
FORALL I IN P_Locations.FIRST .. P_Locations.LAST
Insert into TEMPTBL_NUMBER_SEARCH values(I,P_Locations(I),'DF');
FORALL I IN P_WorkCenters.FIRST .. P_WorkCenters.LAST
Insert into TEMPTBL_NUMBER_SEARCH values(I,P_WorkCenters(I),'WC');
FORALL I IN P_KeyRingIds.FIRST .. P_KeyRingIds.LAST
Insert into TEMPTBL_NUMBER_SEARCH values(I,P_KeyRingIds(I),'KR');
FORALL I IN P_Routes.FIRST .. P_Routes.LAST
Insert into TEMPTBL_NUMBER_SEARCH values(P_Routes(I),'','RT');
END
But now its giving me error
Error(558,49): PLS-00430: FORALL iteration variable I is not allowed in this context
SO which means its taking NULL what should I do?
November 15, 2017 - 2:04 am UTC
Look at my example again - notice I reference the elements of the record, ie
r1(i).owner, r1(i).object_name
not
r1(i)