CREATE OR REPLACE PROCEDURE shanglifeecif.init_insuredno_salecom_relation() IS
DECLARE
BEGIN
 
-- 用户 渠道关系表
	insert into shanglifeecif.insuredno_salecom_relation (
		insuredno,
		salecomname,
		salecom
	) 
	SELECT   insuredno , salecomname ,salecom FROM (
 SELECT     insuredno , salecomname ,salecom  FROM dsj.POLICY_INFORMATION GROUP BY     insuredno , salecomname,salecom
 ) t ;
 
 
dbms_output.put_line('insuredno_salecom_relation 函数跑批完成！');

EXCEPTION
			WHEN HIVE_EXCEPTION THEN 
				 INSERT INTO shanglifeecif.exception_log(log_id,log_code,log_msg,log_time) VALUES (to_char(sysdate(),'yyyyMMddHHmmss'),sqlcode(),sqlerrm(),sysdate());

WHEN Others THEN
				INSERT INTO shanglifeecif.exception_log(log_id,log_code,log_msg,log_time) VALUES (to_char(sysdate(),'yyyyMMddHHmmss'),sqlcode(),sqlerrm(),sysdate());

END;