OM裡保留記錄備份SQL

longwansheng發表於2009-03-31


First:

create table gobo.gobo_om_reservations_2008b as

select * from gobo_om_reservations
where to_char(CREATION_DATE,'yyyy')

delete from gobo_om_reservations
where to_char(CREATION_DATE,'yyyy')

commit

After 2009Year:

create table gobo.gobo_om_reservations_????b as --????=to_char(sysdate-400,'yyyy')
select * from gobo.gobo_om_reservations_2008b

insert into gobo.gobo_om_reservations_????b
select * from gobo_om_reservations
where to_char(CREATION_DATE,'yyyy')

delete from gobo_om_reservations
where to_char(CREATION_DATE,'yyyy')

commit

[@more@]

系統TABLE:mtl_reservations

的TRRIGER如下:

--OTC的訂單在OM發放工單時,會自動保留。

--即把訂單與工單聯系起來,可當訂單銷貨後,

--或工單完工後,該關聯即消失

--為了保持聯系啟用備份的方法。

CREATE OR REPLACE TRIGGER gobo_om_reservations_in
after insert on mtl_reservations
for each row
begin

--舊的方式備份到gobo_om_reservations

insert into gobo_om_reservations
values( :new.SUPPLY_SOURCE_HEADER_ID,
:new.ORGANIZATION_ID,
:new.INVENTORY_ITEM_ID,
:new.DEMAND_SOURCE_TYPE_ID,
:new.DEMAND_SOURCE_HEADER_ID,
:new.DEMAND_SOURCE_LINE_ID,
:new.RESERVATION_QUANTITY,
:new.SUPPLY_SOURCE_TYPE_ID,
:new.CREATION_DATE,
:new.LAST_UPDATE_DATE );

--新的方式,把WIP_JOD_ID寫到訂單LINE裡

--為了人留舊上面的方式,故不取消上面的方法。

update oe_order_lines_all
set attribute19=:new.supply_source_header_id
where line_id= :new.demand_source_line_id
-- and header_id=:new.demand_source_header_id
and attribute19 is null;

end;

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/92289/viewspace-1019655/,如需轉載,請註明出處,否則將追究法律責任。

相關文章