unis_crm/sql/archive/alter_opportunity_confidenc...

22 lines
589 B
MySQL
Raw Permalink Normal View History

-- ensure opportunity confidence dictionary exists
begin;
insert into sys_dict_item (type_code, item_label, item_value, sort_order, status, is_deleted, remark)
select v.type_code, v.item_label, v.item_value, v.sort_order, 1, 0, '商机项目把握度'
from (
values
('sj_xmbwd', 'A', 'A', 1),
('sj_xmbwd', 'B', 'B', 2),
('sj_xmbwd', 'C', 'C', 3)
) as v(type_code, item_label, item_value, sort_order)
where not exists (
select 1
from sys_dict_item s
where s.type_code = v.type_code
and s.item_value = v.item_value
and coalesce(s.is_deleted, 0) = 0
);
commit;