You are on page 1of 2

PROMPT

PROMPT INV17-backup.sql
PROMPT From Note:1472074.1 Inventory Standard Datafix Instruction #17: Fixing Du
plicate Sales Order Transactions In MTI, MMTT and MMT
PROMPT
PROMPT Views are created to facilitate SQL for backup tables.
PROMPT a. View Table MMT vs. MTI
create or replace view mmt_mti_records_v as
select a.transaction_interface_id ,
a.picking_line_id from
mtl_material_transactions b, mtl_transactions_interface a
where a.picking_line_id = b.picking_line_id
and a.trx_source_line_id = b.trx_source_line_id
and a.inventory_item_id = b.inventory_item_id
and b.transaction_type_id = a.transaction_type_id
and b.transaction_source_type_id in (2,8)
and b.picking_line_id is not null ;
PROMPT b. View Table MMTT vs. MTI
create or replace view mmtt_mti_records_v as
select a.transaction_interface_id ,
a.picking_line_id from
mtl_material_transactions_temp b, mtl_transactions_interface a
where a.picking_line_id = b.picking_line_id
and a.trx_source_line_id = b.trx_source_line_id
and a.inventory_item_id = b.inventory_item_id
and b.transaction_type_id = a.transaction_type_id
and b.transaction_source_type_id in (2,8)
and b.picking_line_id is not null ;
PROMPT c. View MMT vs. MMTT
create or replace view mmt_mmtt_records_v as
select a.transaction_temp_id,
a.picking_line_id from
mtl_material_transactions b, mtl_material_transactions_temp a
where a.picking_line_id = b.picking_line_id
and a.trx_source_line_id = b.trx_source_line_id
and a.inventory_item_id = b.inventory_item_id
and b.transaction_type_id = a.transaction_type_id
and b.transaction_source_type_id in ( 2,8)
and b.picking_line_id is not null;
PROMPT Create Backup table: mti_dup_backup
create table mti_dup_backup_13sep as (select * from mtl_transactions_interface
where transaction_interface_id in (select transaction_interface_id from mmt_mti_
records_v));
PROMPT Create Backup table: msni_dup_backup
create table msni_dup_backup_13sep as (select * from mtl_serial_numbers_interfac
e
where transaction_interface_id in (select transaction_interface_id from mmt_mti_
records_v))
union
(select * from mtl_serial_numbers_interface msni where msni.transaction_interfac
e_id in (
select mtli.serial_transaction_temp_id
from mtl_transaction_lots_interface mtli
where mtli.transaction_interface_id in (select transaction_interface_id from
mmt_mti_records_v )));

PROMPT Create Backup table: mtli_dup_backup


create table mtli_dup_backup_13sep as (select * from mtl_transaction_lots_interf
ace where transaction_interface_id in (select transaction_interface_id from mmt_
mti_records_v));
PROMPT Create Backup table: mti_dup_backup_mmtt
create table mti_dup_backup_mmtt_13sep as (select * from mtl_transactions_interf
ace
where transaction_interface_id in (select transaction_interface_id from mmtt_mti
_records_v));
PROMPT Create Backup table: msni_dup_backup_mmtt
create table msni_dup_backup_mmtt_13sep as (select * from mtl_serial_numbers_int
erface
where transaction_interface_id in (select transaction_interface_id from mmtt_mti
_records_v))
union
(select * from mtl_serial_numbers_interface msni where msni.transaction_interfac
e_id in (
select mtli.serial_transaction_temp_id
from mtl_transaction_lots_interface mtli
where mtli.transaction_interface_id in (select transaction_interface_id from
mmtt_mti_records_v )));
PROMPT Create Backup table: mtli_dup_backup_mmtt
create table mtli_dup_backup_mmtt_13sep as (select * from mtl_transaction_lots_i
nterface where transaction_interface_id in (select transaction_interface_id from
mmtt_mti_records_v));
PROMPT Create Backup table: mmtt_dup_backup
create table mmtt_dup_backup_13sep as (select * from mtl_material_transactions_t
emp
where transaction_temp_id in (select transaction_temp_id from mmt_mmtt_records_v
));
PROMPT Create Backup table: msnt_dup_backup
create table msnt_dup_backup_13sep as
(select * from mtl_serial_numbers_temp
where transaction_temp_id in (select transaction_temp_id from mmt_mmtt_records_v
))
union
(select * from mtl_serial_numbers_temp msnt where msnt.transaction_temp_id in (
select mtlt.serial_transaction_temp_id
from mtl_transaction_lots_temp mtlt
where mtlt.transaction_temp_id in (select transaction_temp_id from
mmt_mmtt_records_v )));
PROMPT Create Backup table: mtlt_dup_backup
create table mtlt_dup_backup_13sep as (select * from mtl_transaction_lots_temp
where transaction_temp_id in (select transaction_temp_id from mmt_mmtt_records_
v ));
PROMPT Commit
COMMIT;