update_insuredinfo.sql 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. CREATE OR REPLACE PROCEDURE shanglifeecif.update_insuredinfo()
  2. IS
  3. BEGIN
  4. --更新被保人信息
  5. UPDATE shanglifeecif.individual a SET (
  6. ZIPCODE,--邮编
  7. HPhone,--电话
  8. PMPhone,--手机
  9. email, -- 邮箱
  10. RAL, --联系地址
  11. sobirth --省份
  12. ) = (
  13. SELECT
  14. t.zipcode,
  15. t.phone,
  16. t.mobile,
  17. t.email,
  18. regexp_replace(trim(t.address),'[0-9]','*') address,
  19. regexp_extract(t.address,'(.*?)省|(.*?)市',0) province
  20. FROM (
  21. SELECT
  22. row_number()OVER(PARTITION BY ls.customerno ORDER BY ls.modifydate desc) rn,
  23. ls.customerno,--客户号
  24. CASE
  25. WHEN ls.postaladdress IS NULL
  26. THEN
  27. CASE WHEN ls.homeaddress IS NULL THEN ls.companyaddress ELSE ls.homeaddress END
  28. ELSE ls.postaladdress
  29. END AS address,
  30. ls.phone,
  31. ls.zipcode,--邮编
  32. CASE WHEN ls.email IS NULL THEN ls.email2 ELSE ls.email END AS email,
  33. CASE WHEN ls.mobile IS NULL THEN ls.mobile2 ELSE ls.mobile END AS mobile
  34. FROM dsj.lcaddress ls
  35. ) t where t.rn = 1 AND t.customerno = a.scustid
  36. ) WHERE a.custtype = '被保人';
  37. UPDATE shanglifeecif.individual a SET (
  38. Height, --身高
  39. Weight, --体重
  40. BMI,
  41. PIncome, --个人年收入
  42. Ethnic, --民族情况
  43. Nation, --国籍
  44. MaritalStat, --婚姻
  45. Education,--学历
  46. SIStatus,--社保
  47. IncomeSource,--收入来源
  48. Occupation,--职业
  49. regtype --户籍类型
  50. ) = (
  51. SELECT
  52. t.stature,--身高
  53. t.avoirdupois,--体重
  54. t.bmi,
  55. t.yearincome,
  56. t.nationality,--民族
  57. t.nativeplace,--国籍
  58. t.marriage, --婚姻状况
  59. t.degree, --学历
  60. t.socialinsuflag,--社保
  61. t.incomesource,--收入来源
  62. t.occupationcode,--职业
  63. t.dentype
  64. FROM (
  65. SELECT
  66. row_number()OVER(PARTITION BY ld.insuredno ORDER BY ld.modifydate desc) rn,
  67. ld.insuredno,--被保人客户号
  68. ld.appntno,--投保人客户号
  69. ld.name,--被保人名称
  70. ld.sex,--被保人性别
  71. ld.birthday,--被保人出生日期
  72. ld.idtype,--证件类型
  73. ld.idno,--证件号码
  74. ld.marriage,--婚姻状况
  75. ld.occupationcode,--职业
  76. ld.nativeplace,--国籍
  77. ld.nationality,--民族
  78. ld.stature,--身高
  79. ld.avoirdupois,--体重
  80. round((ld.avoirdupois/POWER((ld.stature/100),2)),2) bmi,
  81. ld.degree,--学历
  82. ld.dentype,--居民类型
  83. ld.socialinsuflag,--社保情况
  84. ld.incomesource,--收入来源
  85. ld.yearincome --年收入
  86. FROM dsj.lcinsured2 ld
  87. ) t WHERE t.rn = 1 AND t.insuredno = a.scustid
  88. ) WHERE a.custtype = '被保人';
  89. dbms_output.put_line('update_insuredinfo函数跑批完成!');
  90. EXCEPTION
  91. WHEN HIVE_EXCEPTION THEN
  92. INSERT INTO shanglifeecif.exception_log(log_id,log_code,log_msg,log_time) VALUES (to_char(sysdate(),'yyyyMMddHHmmss'),sqlcode(),sqlerrm(),sysdate());
  93. WHEN Others THEN
  94. INSERT INTO shanglifeecif.exception_log(log_id,log_code,log_msg,log_time) VALUES (to_char(sysdate(),'yyyyMMddHHmmss'),sqlcode(),sqlerrm(),sysdate());
  95. END;