Good Afternoon,
I need some help understanding buld collections and their use in a forall statement. I want to update multiple rows in a table based on the results set of a query (cursor). A simplified example of my current statement is shown below. It's been thought several interations as I try to understand how the bulk collection and forall statements work. I'd appreciate any assistance you might give, including definitions of the various conventions in this type of action.
declare
cursor Item_Master_Export is select
item_master.item_no as item,
item_location.stock_area as Warehouse
from warehouse_info,
item_location,
item_master
where
warehouse_info.warehouse_flag='P'
and item_location.stock_area
=warehouse_info.warehouse_id
and item_master.item_no = item_location.item_no;
Type Item_Table is Table of Item_Master_Export%rowtype
INDEX BY pls_integer;
Eligible_items item_table;
begin
open Item_Master_Export;
fetch Item_Master_Export Bulk Collect into Eligible_Items;
close Item_Master_Export;
forall indx in eligible_items.first..eligible_items.last
Update item_location set last_extract_date=sysdate,
extract_req='N'
where item_location.item_no = item(indx)
and stock_area=warehouse(indx);
end;
I have tried Feuerstein's book, but he assumes more knowledge of the pieces than I bring to the table in his examples.
Thanks you
Jax
I need some help understanding buld collections and their use in a forall statement. I want to update multiple rows in a table based on the results set of a query (cursor). A simplified example of my current statement is shown below. It's been thought several interations as I try to understand how the bulk collection and forall statements work. I'd appreciate any assistance you might give, including definitions of the various conventions in this type of action.
declare
cursor Item_Master_Export is select
item_master.item_no as item,
item_location.stock_area as Warehouse
from warehouse_info,
item_location,
item_master
where
warehouse_info.warehouse_flag='P'
and item_location.stock_area
=warehouse_info.warehouse_id
and item_master.item_no = item_location.item_no;
Type Item_Table is Table of Item_Master_Export%rowtype
INDEX BY pls_integer;
Eligible_items item_table;
begin
open Item_Master_Export;
fetch Item_Master_Export Bulk Collect into Eligible_Items;
close Item_Master_Export;
forall indx in eligible_items.first..eligible_items.last
Update item_location set last_extract_date=sysdate,
extract_req='N'
where item_location.item_no = item(indx)
and stock_area=warehouse(indx);
end;
I have tried Feuerstein's book, but he assumes more knowledge of the pieces than I bring to the table in his examples.
Thanks you
Jax