PLSQL存储过程传出大量异常错误信息

1:  plsql存储过程中将程序大量异常错误信息,以clob类型变量传出

 

CREATE OR REPLACE PROCEDURE list_product_read(p_code     IN OUT NOCOPY NUMBER,
                                              p_err_mesg IN OUT NOCOPY CLOB) AS
    ----------------------------------------------------------------------------------------
    --商品目录接口下发
    --1.Date:20180724
    --Author:xeeyung
    --Description:
    --

    --------------------------------------------------------------------------------------------------------
    v_log VARCHAR2(4000);

    v_strs VARCHAR2(32767);
    v_clob CLOB;

BEGIN
    p_code := 0;
    dbms_lob.createtemporary(v_clob, TRUE);
    
    FOR v IN (SELECT t.id, t.ad_client_id, t.ad_org_id, t.ownerid, t.prod_id,
                     t.name, t.basic_uom, t.orientation, t.status1, t.puc_mode,
                     t.prod_year, t.prod_season, t.for_season, t.series,
                     t.themedesign, t.prod_partm, t.prod_group, t.prod_sub_group,
                     t.old_brand_id, t.brand_id, t.prod_sorts, t.prod_line
              FROM list_product t
              WHERE t.ediflag = 80) LOOP
        BEGIN
        --业务逻辑
        
            --COMMIT;
        EXCEPTION
            WHEN OTHERS THEN
                --ROLLBACK;
v_log := SQLERRM; p_code := 1; v_strs := '-款号[' || v.prod_id || ']:' || v_log; dbms_lob.append(v_clob, v_strs); END; END LOOP; p_err_mesg := v_clob; dbms_lob.freetemporary(v_clob); END;

  

posted @ 2018-11-12 17:46  MorePrograms  阅读(490)  评论(0编辑  收藏  举报