CREATE OR REPLACE FUNCTION "public"."proc_net_agent_diamond_loss"("dwuserid" int4, "strdate" date) RETURNS "public"."my_returninfo" AS $BODY$ DECLARE result My_ReturnInfo; v_start_time TIMESTAMP(0); v_end_time TIMESTAMP(0); cur_agent_loss_diamond_info refcursor; v_user_id INT; v_club_list varchar(4000); err_message varchar(4000); exception_context varchar(4000); BEGIN IF strDate is null then strDate := (now()::DATE-interval '1 day'); END IF; result.strErrorDescribe='数据录入成功'||strDate; result.ReturnValue=0; RETURN result; EXCEPTION WHEN OTHERS THEN BEGIN -- get stacked diagnostics exception_context=PG_EXCEPTION_CONTEXT; --获取错误的行号 --err_message := '错误行号:' || exception_context || '; 异常:' || sqlerrm; --insert into proc_err_log values(err_message); result.strErrorDescribe='数据异常已经回滚'; --获取异常信息 result.ReturnValue=9999; RETURN result; END; END; $BODY$ LANGUAGE plpgsql VOLATILE COST 100
标签:postgresql,函数,err,--,4000,捕捉,result,END,message From: https://www.cnblogs.com/xiexie0223/p/17326397.html