Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- procedure insert_plan_to_dep_show_char
- as
- begin
- merge
- into dep_show_char c
- using (
- select 20355682000000 as form_id, c.object_id as char_id, c.is_plan
- from dep_bonus_char c left join dep_product p on c.product_id = p.object_id
- where c.is_plan = cst.true
- and c.type_id in ( dep_bonus_char_type_cst.purchase_sum, dep_bonus_char_type_cst.share_in_total, dep_bonus_char_type_cst.urgent_percent, dep_bonus_char_type_cst.any_char)
- and c.val_id in ( cst.num, cst.txt )
- and c.act_start_date >= to_date('01.01.2016','DD.MM.YYYY') and c.act_end_date < to_date('01.01.2018','DD.MM.YYYY')
- ) s
- on ( s.form_id = c.form_id
- and s.char_id = c.char_id
- )
- when matched then update set
- c.is_plan = s.is_plan
- when not matched then insert
- ( form_id, char_id, is_plan)
- values
- ( s.form_id, s.char_id, s.is_plan);
- end;
- /
- procedure insert_fact_to_dep_show_char
- as
- begin
- merge
- into dep_show_char c
- using (
- select 20355682010000 as form_id, c.object_id as char_id, c.is_fact, c.product_id
- from dep_bonus_char c left join dep_product p on c.product_id = p.object_id
- left join dep_uom u on c.uom_id = u.object_id
- where c.type_id not in (
- dep_bonus_char_type_cst.bonus_percent
- , dep_bonus_char_type_cst.mix
- , dep_bonus_char_type_cst.group_minus
- , dep_bonus_char_type_cst.bonus_sum
- , dep_bonus_char_type_cst.share_in_total
- )
- and c.val_id in ( cst.num, cst.fle, cst.txt )
- and not (
- c.type_id = dep_bonus_char_type_cst.purchase_sum
- and c.product_id = dep_product_cst.car
- and c.uom_id = dep_uom_cst.rub
- ) and c.type_id not in ( dep_bonus_char_type_cst.total_bonus_percent, dep_bonus_char_type_cst.help)
- and (c.is_fact = cst.true or c.type_id = dep_bonus_char_type_cst.min_plan)
- /* and (v_object_type_id = AP_DATA_TYPE_CST.bonus_fact and c.type_id not in (dep_bonus_char_type_cst.indep_char) or
- v_object_type_id = AP_DATA_TYPE_CST.other_chars and c.type_id in (dep_bonus_char_type_cst.indep_char))*/
- and act_start_date >= to_date('01.01.2016','DD.MM.YYYY') and act_end_date < to_date('01.01.2018','DD.MM.YYYY')
- ) s
- on ( s.form_id = c.form_id
- and s.char_id = c.char_id
- )
- when matched then update set
- c.is_fact = s.is_fact
- when not matched then insert
- ( form_id, char_id, is_fact)
- values
- ( s.form_id, s.char_id, s.is_fact);
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement