You have a couple of options. total_area
doesn't exist outside the record type you've defined, so you can't use it in an if
where you've shown, but you can just adjust that slightly:
...
For i in 1..c1_list.count loop
if c1_list(i).total_area=100
then
insert into temp_Prop_area_100
values c1_list(i);
else
insert into temp_Prop_area_block
values c1_list(i);
end if;
End Loop;
End Loop;
End;
Or you can split your list into two:
Type C1_TAB_TYPE is table of c1%ROWTYPE;
c1_list c1_TAB_TYPE;
c1_list_100 c1_TAB_TYPE;
c1_list_block c1_TAB_TYPE;
...
For i in 1..c1_list.count loop
if c1_list(i).total_area=100
then
c1_list_100.extend();
c1_list_100(c1_list_100.last) := c1_list(i);
else
c1_list_block.extend();
c1_list_block(c1_list_block.last) := c1_list(i);
end if;
End Loop;
For i in 1..c1_list_100.count loop
insert into temp_Prop_area_100
values c1_list_100(i);
End Loop;
For i in 1..c1_list_block.count loop
insert into temp_Prop_area_block
values c1_list_block(i);
End Loop;
End Loop;
End;
Which looks like its adding extra complexity for not much gain, which is maybe true if you continue to use individual inserts. But that also allows you to use the forall
syntax mentioned in a previous answer:
Type C1_TAB_TYPE is table of temp_prop_area%ROWTYPE;
...
Forall i in 1..c1_list_100.count
insert into temp_Prop_area_100
values c1_list_100(i);
Forall i in 1..c1_list_block.count
insert into temp_Prop_area_block
values c1_list_block(i);
End Loop;
End;
You could also do separate select ... bulk collect
statements into the two lists, with different filters, but that involves hitting the tables twice and is likely to be less efficient.