The following lines contain the word 'select', 'insert', 'update' or 'delete':
Select a.transaction_id
, a.organization_id
, a.inventory_item_id
, nvl(a.transaction_source_id , 0) transaction_source_id
, a.transaction_source_type_id
, a.trx_source_delivery_id
, a.trx_source_line_id
, a.revision
, a.subinventory_code
, a.locator_id
, a.primary_quantity
, a.transaction_quantity
, a.transaction_source_name
, a.transaction_date
, d.reference2
, b.quantity
, b.source_header_id
, d.task_id
, b.unit_number
From mtl_system_items c
, mtl_material_transactions a
, oke_deliverables_b b
, oke_deliverable_actions d
, mrp_schedule_dates m
where a.source_code = 'OKE'
And a.organization_id = c.organization_id
And a.inventory_item_id = c.inventory_item_id
And a.primary_quantity < 0
And a.transaction_source_type_id = 16
-- And a.transaction_source_id = b.source_header_id bug 3863976
And a.transaction_source_id = -99 -- bug 3863976
And b.deliverable_id = d.deliverable_id
And b.source_code = 'PA'
And d.action_id = a.source_line_id
And m.mps_transaction_id = d.reference2
And m.schedule_level = 2
And m.supply_demand_type = 1
And m.schedule_quantity > 0
And a.transaction_id > nvl( m.old_transaction_id , 0 )
Order by a.transaction_id asc;
Select schedule_quantity, schedule_date, old_transaction_id
From Mrp_Schedule_Dates
Where mps_transaction_id = l_transaction_id
And Schedule_Level = 2
And Schedule_Quantity > 0
For Update Of schedule_quantity;
Select count(*) from mrp_schedule_consumptions
Where disposition_id = l_disposition_id;
update mrp_schedule_dates
set schedule_quantity = l_qty,
last_update_date = sysdate,
last_updated_by = fnd_global.user_id,
request_id = fnd_global.conc_request_id,
program_application_id = fnd_global.prog_appl_id,
program_id = fnd_global.conc_program_id,
program_update_date = sysdate,
old_transaction_id = l_mds_tbl(i).mtl_transaction_id
where mps_transaction_id = l_mds_tbl(i).mps_transaction_id
and schedule_level = 2;
write_log( 'MDS entry updated' );
INSERT INTO mrp_schedule_consumptions
(transaction_id,
relief_type,
disposition_type,
disposition_id,
line_num,
last_update_date,
last_updated_by,
creation_date,
created_by,
last_update_login,
request_id,
program_application_id,
program_id,
program_update_date,
order_date,
order_quantity,
relief_quantity,
schedule_date)
VALUES
(
l_mds_tbl(i).mps_transaction_id,
1, -- MDS_RELIEF 1, MPS_RELIEF 2
3, -- R_WORK_ORDER 1, R_PURCH_ORDER 2, R_SALES_ORDER 3
null, -- l_mds_tbl(i).mtl_transaction_id,
null, -- No order line_num
SYSDATE,
fnd_global.user_id,
SYSDATE,
fnd_global.user_id,
fnd_global.login_id,
fnd_global.conc_request_id,
fnd_global.prog_appl_id,
fnd_global.conc_program_id,
SYSDATE,
l_mds_tbl(i).transaction_date,
l_mds_tbl(i).order_quantity,
l_mds_tbl(i).primary_quantity * -1,
l_schedule_date);