123456789101112131415161718192021222324252627282930313233 |
- CREATE OR REPLACE PROCEDURE shanglifeecif.riskcode_statistics() IS
- DECLARE
- BEGIN
- DELETE FROM shanglifeecif.riskcode_statistics;
- insert into shanglifeecif.riskcode_statistics (
- id,
- kindName,
- khnum,
- tatolprem
- ) --险种大类统计
- SELECT
- row_number()over(),
- temp.kindName,
- temp.khnum,
- temp.tatolprem
- FROM (
- SELECT
- crt.riskcategoriesname AS kindName,
- count(DISTINCT scustid) AS khnum,
- sum(risk) AS tatolprem
- FROM shanglifeecif.customer_risk_temp crt
- WHERE crt.riskcategoriesname IS NOT null
- GROUP BY crt.riskcategoriesname
-
- ) temp;
- dbms_output.put_line('riskcode_statistics函数跑批完成!');
- EXCEPTION
- WHEN HIVE_EXCEPTION THEN
- INSERT INTO shanglifeecif.exception_log(log_id,log_code,log_msg,log_time) VALUES (to_char(sysdate(),'yyyyMMddHHmmss'),sqlcode(),sqlerrm(),sysdate());
- WHEN Others THEN
- INSERT INTO shanglifeecif.exception_log(log_id,log_code,log_msg,log_time) VALUES (to_char(sysdate(),'yyyyMMddHHmmss'),sqlcode(),sqlerrm(),sysdate());
- END ;
|