Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- begin
- merge into {bitlog_schema}.sorderlines sol
- using
- (
- select
- gtt.soid, gtt.ln, gtt.artid, gtt.qty, gtt.prc, gtt.curency, gtt.cartons, gtt.type, gtt.vat, gtt.year_reserve, gtt.number_reserve,pcb
- from {bitlog_schema}.{gtt_solines_table} gtt
- ) gtt
- on (sol.soid = gtt.soid and sol.ln = gtt.ln and sol.artid = gtt.artid and sol.pcb = gtt.pcb)
- when matched then
- update set
- sol.qty = gtt.qty,
- sol.curency = gtt.curency,
- sol.cartons = gtt.cartons,
- sol.type = gtt.type,
- sol.vat = gtt.vat,
- sol.year_reserve = gtt.year_reserve,
- sol.number_reserve = gtt.number_reserve,
- sol.prc = gtt.prc
- where
- (
- (sol.qty != gtt.qty) or
- (sol.curency != gtt.curency) or
- (sol.cartons != gtt.cartons) or
- (sol.type != gtt.type) or
- (sol.vat != gtt.vat) or
- (sol.year_reserve != gtt.year_reserve) or
- (sol.number_reserve != gtt.number_reserve) or
- (sol.prc != gtt.prc)
- )
- when not matched then
- insert (sol.soid, sol.ln, sol.artid, sol.qty, sol.prc, sol.curency, sol.cartons, sol.type, sol.vat, sol.year_reserve, sol.number_reserve,sol.pcb)
- values (gtt.soid, gtt.ln, gtt.artid, gtt.qty, gtt.prc, gtt.curency, gtt.cartons, gtt.type, gtt.vat, gtt.year_reserve, gtt.number_reserve,gtt.pcb);
- commit;
- delete
- from {bitlog_schema}.sorderlines sol
- where
- not exists
- (select 1
- from
- {bitlog_schema}.{gtt_solines_table} gtt
- where
- sol.soid = gtt.soid
- and sol.ln = gtt.ln
- and sol.artid = gtt.artid)
- and sol.soid in (select gtt.soid from {bitlog_schema}.{gtt_solines_table} gtt group by gtt.soid);
- commit;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement