up_t_customers_class_1.sql 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. CREATE OR REPLACE PROCEDURE shanglifeecif.up_t_customers_class_1() -- 创建存储过程
  2. IS
  3. BEGIN
  4. UPDATE shanglifeecif.individual a SET (
  5. CustClass ,-- 客户等级
  6. ConValue ,-- 贡献度分
  7. Awarded3 ,-- 家庭加分2
  8. Awarded2 ,-- 续期加分
  9. Awarded1 ,-- 保单加分
  10. SOValue ,-- 总分值
  11. EndDate, -- 客户等级失效日期
  12. Height, --身高
  13. Weight, --体重
  14. BMI,
  15. PIncome, --个人年收入
  16. FIncome, --家庭年收入
  17. IncomeSource, --收入来源
  18. SIStatus, --社保情况
  19. --Ethnic, --民族情况
  20. Nation, --国籍
  21. MaritalStat, --婚姻
  22. Employer,--工作单位
  23. --Education,--学历
  24. Dday, --死亡日期
  25. regtype, --户籍类型
  26. ZIPCODE,--邮编
  27. HPhone,--电话
  28. PMPhone,--手机
  29. email, -- 邮箱
  30. RAL, --联系地址
  31. sobirth --省份
  32. ) = (
  33. select
  34. b.CLASS_VALUE,--客户等级
  35. b.CONTRIBUTION_VALUE,--贡献度分
  36. b.AWARDED3, --家庭加分
  37. b.AWARDED2, --续期加分
  38. b.AWARDED1, --保单加分
  39. b.TOTAL_VALUE, --总分值
  40. trim(b.END_DATE) as END_DATE, --失效日期
  41. b.STATURE, --身高
  42. b.AVOIRDUPOIS,--体重
  43. b.BMI, --根据身高体重计算
  44. b.YEARINCOME, --个人年收入
  45. b.FAMILYYEARSALARY, --家庭年收入
  46. trim(b.INCOMESOURCE) as INCOMESOURCE, --收入来源
  47. trim(b.SOCIALINSUFLAG) as SOCIALINSUFLAG, --社保情况
  48. --trim(b.NATIONALITY) as NATIONALITY, --民族情况
  49. trim(b.NATIVEPLACE) as NATIVEPLACE, --国籍
  50. trim(b.MARRIAGE) as MARRIAGE,--婚姻
  51. trim(b.GRPNAME) as GRPNAME,--工作单位名称
  52. --trim(b.DEGREE) as DEGREE,--学历
  53. trim(b.DEATHDATE) as DEATHDATE,--死亡日期
  54. trim(b.DENTYPE) as DENTYPE,--户籍类型
  55. trim(b.ZIPCODE) as ZIPCODE,--邮编
  56. trim(b.PHONE) as PHONE,--电话
  57. trim(b.MOBILE) as MOBILE,--手机
  58. trim(b.EMAIL) as EMAIL,--邮箱
  59. regexp_replace(trim(b.POSTALADDRESS),'[0-90-9]','*') as POSTALADDRESS, --联系地址
  60. regexp_extract(b.POSTALADDRESS,'(.*?)省|(.*?)市',0) -- 省份
  61. from dsj.t_customer_class b
  62. where b.CUSTOMER_ID = a.scustid
  63. ) WHERE 1=1 ;
  64. dbms_output.put_line('up_t_customers_class_1函数跑批完成!');
  65. EXCEPTION
  66. WHEN HIVE_EXCEPTION THEN
  67. INSERT INTO shanglifeecif.exception_log(log_id,log_code,log_msg,log_time) VALUES (to_char(sysdate(),'yyyyMMddHHmmss'),sqlcode(),sqlerrm(),sysdate());
  68. WHEN Others THEN
  69. INSERT INTO shanglifeecif.exception_log(log_id,log_code,log_msg,log_time) VALUES (to_char(sysdate(),'yyyyMMddHHmmss'),sqlcode(),sqlerrm(),sysdate());
  70. END;