partytimeline_tuibao.sql 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. CREATE OR REPLACE PROCEDURE shanglifeecif.partytimeline_tuibao()
  2. IS
  3. DECLARE
  4. p_count int
  5. BEGIN
  6. insert into shanglifeecif.partytimeline (
  7. TripID,
  8. PolicyNo,
  9. PartyID,
  10. name,
  11. PRole,
  12. Scenario,
  13. SDate,
  14. DESCRIBE,
  15. created_by ,
  16. created_time
  17. ) SELECT
  18. reflect("java.util.UUID", "randomUUID"),
  19. trim(t.contno) as contno,
  20. trim(t.customerno) as customerno,
  21. trim(t.name) as name,
  22. trim(t.tbr) as tbr,
  23. trim(t.tb) as tb,
  24. trim(t.edorappdate) as edorappdate,
  25. t.edorreason,
  26. 'admin',
  27. sysdate()
  28. FROM (
  29. SELECT
  30. row_number() over(partition by i.contno) rn,
  31. lm.contno,
  32. i.customerno,
  33. i.name,
  34. '投保人' AS tbr,
  35. '退保' AS tb,
  36. to_char(lm.edorappdate,"yyyy-MM-dd") edorappdate,
  37. CASE lm.edorreasoncode
  38. WHEN '01' THEN '死亡'
  39. WHEN '02' THEN '失踪'
  40. WHEN '03' THEN '离异'
  41. WHEN '04' THEN '债权转移'
  42. WHEN '05' THEN '被保险人成年'
  43. WHEN '06' THEN '其它'
  44. ELSE '其它'
  45. END AS edorreason
  46. FROM dsj.lpedoritem lm,dsj.policy_information i
  47. where lm.contno = i.contno AND lm.edortype='CT' AND lm.edorstate = 0
  48. ) t WHERE t.rn = 1;
  49. dbms_output.put_line('partytimeline_tuibao函数跑批完成!');
  50. EXCEPTION
  51. WHEN HIVE_EXCEPTION THEN
  52. INSERT INTO shanglifeecif.exception_log(log_id,log_code,log_msg,log_time) VALUES (to_char(sysdate(),'yyyyMMddHHmmss'),sqlcode(),sqlerrm(),sysdate());
  53. WHEN Others THEN
  54. INSERT INTO shanglifeecif.exception_log(log_id,log_code,log_msg,log_time) VALUES (to_char(sysdate(),'yyyyMMddHHmmss'),sqlcode(),sqlerrm(),sysdate());
  55. END;