customer_risk_temp.sql 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. CREATE OR REPLACE PROCEDURE shanglifeecif.customer_risk_temp()
  2. IS
  3. DECLARE
  4. BEGIN
  5. DELETE FROM shanglifeecif.customer_risk_temp;
  6. INSERT INTO shanglifeecif.customer_risk_temp(
  7. id,
  8. scustid,
  9. name,
  10. gender,
  11. idcard,
  12. birthday,
  13. policyno,
  14. productname,
  15. riskcategoriesname,
  16. risk,
  17. salecom,
  18. salecomname
  19. )
  20. SELECT
  21. row_number()over(),
  22. si.scustid,
  23. si.name,
  24. CASE si.gender
  25. WHEN '0' THEN '男'
  26. WHEN '1' THEN '女'
  27. END AS gender,
  28. si.idcard,
  29. to_char(si.birthday,"yyyy-MM-dd") birthday,
  30. sit.policyno,
  31. sit.productname,
  32. sit.risk_categories_name,
  33. sit.Risk,
  34. sit.policybelong,
  35. sit.salecomname
  36. FROM shanglifeecif.individual si
  37. LEFT JOIN shanglifeecif.insurancearrangement sit ON si.scustid = sit.insuredscustid;
  38. dbms_output.put_line('customer_risk_temp函数跑批完成!');
  39. EXCEPTION
  40. WHEN HIVE_EXCEPTION THEN
  41. INSERT INTO shanglifeecif.exception_log(log_id,log_code,log_msg,log_time) VALUES (to_char(sysdate(),'yyyyMMddHHmmss'),sqlcode(),sqlerrm(),sysdate());
  42. WHEN Others THEN
  43. INSERT INTO shanglifeecif.exception_log(log_id,log_code,log_msg,log_time) VALUES (to_char(sysdate(),'yyyyMMddHHmmss'),sqlcode(),sqlerrm(),sysdate());
  44. END ;