init_all_individual.sql 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. CREATE OR REPLACE PROCEDURE shanglifeecif.init_all_individual() -- 初始化所有客户信息
  2. IS
  3. BEGIN
  4. --查询出此次处理的数据并出表中
  5. insert into shanglifeecif.individual (
  6. indid,
  7. custid,
  8. scustid,
  9. name,
  10. gender,
  11. birthday,
  12. idcard,
  13. Passport,
  14. Dlicense,
  15. OtherIdNumber,
  16. created_time,
  17. created_by
  18. ) SELECT
  19. row_number()OVER(ORDER BY sc.scustid),
  20. 'CP'||lpad(row_number()over(ORDER BY sc.scustid),10,'0'),
  21. sc.scustid,
  22. sc.name,
  23. sc.gender,
  24. sc.birthday,
  25. CASE sc.idtype WHEN '0' THEN sc.idcard END AS idcard,
  26. CASE sc.idtype WHEN '1' THEN sc.idcard END AS passport,
  27. CASE sc.idtype WHEN '3' THEN sc.idcard END AS dlicense,
  28. CASE WHEN sc.idtype <> '0' AND sc.idtype <> '1' AND sc.idtype <> '3' THEN sc.idcard END AS otherIdnumber,
  29. sysdate,
  30. 'admin'
  31. FROM shanglifeecif.customertotaltemp sc ORDER BY sc.scustid;
  32. dbms_output.put_line('init_all_individual函数跑批完成!');
  33. EXCEPTION
  34. WHEN HIVE_EXCEPTION THEN
  35. INSERT INTO shanglifeecif.exception_log(log_id,log_code,log_msg,log_time) VALUES (to_char(sysdate(),'yyyyMMddHHmmss'),sqlcode(),sqlerrm(),sysdate());
  36. WHEN Others THEN
  37. INSERT INTO shanglifeecif.exception_log(log_id,log_code,log_msg,log_time) VALUES (to_char(sysdate(),'yyyyMMddHHmmss'),sqlcode(),sqlerrm(),sysdate());
  38. END;