surrender_protection_temp.sql 905 B

123456789101112131415161718
  1. CREATE OR REPLACE PROCEDURE shanglifeecif.surrender_protection_temp() IS
  2. DECLARE
  3. BEGIN
  4. DELETE FROM shanglifeecif.surrenderprotectiontemp;
  5. insert into shanglifeecif.surrenderprotectiontemp(
  6. tbid,
  7. scustid,
  8. tbday
  9. )SELECT row_number()over(),p.customerno,max(DATEDIFF(t.edorappdate,p.cvalidate)) AS tbday FROM dsj.lpedoritem t,dsj.policy_information p
  10. WHERE t.contno = p.contno and t.edortype='CT' AND edorstate = 0 GROUP BY p.customerno;
  11. dbms_output.put_line('surrender_protection_temp函数跑批完成!');
  12. EXCEPTION
  13. WHEN HIVE_EXCEPTION THEN
  14. INSERT INTO shanglifeecif.exception_log(log_id,log_code,log_msg,log_time) VALUES (to_char(sysdate(),'yyyyMMddHHmmss'),sqlcode(),sqlerrm(),sysdate());
  15. WHEN Others THEN
  16. INSERT INTO shanglifeecif.exception_log(log_id,log_code,log_msg,log_time) VALUES (to_char(sysdate(),'yyyyMMddHHmmss'),sqlcode(),sqlerrm(),sysdate());
  17. END ;