• oracle的异常处理


      /**
         写入自动施封命令:【同步webservice使用】
         wyg 2017-03-12
      */
      PROCEDURE ISDT_VEHICLE_AutoLock(P_WID       IN VARCHAR2,
                                      P_VEHICLENO IN VARCHAR2,
                                      P_STATE     OUT INT,
                                      P_MSG       OUT VARCHAR2) IS
      BEGIN
        insert into t_isdt_elockautorequest
          (requestid,
           wid,
           vehicleno,
           operatetype,
           created_date,
           last_updated_date)
        values
          (sys_guid(), P_WID, P_VEHICLENO, 1, sysdate, sysdate);
        COMMIT;
        P_STATE := 1;
        P_MSG   := 'success';
      EXCEPTION
        WHEN OTHERS THEN
          rollback;
          P_STATE := 0;
          P_MSG   := SUBSTRB('line:' || dbms_utility.format_error_backtrace() ||
                             ' Occur error;' || SQLCODE || ',' || SQLERRM,
                             1,
                             200);
      END;
    

      

     EXCEPTION
        WHEN DUP_VAL_ON_INDEX THEN
          INSERT INTO t_isdt_vehicle_track_err
            (car_num,
             gpstime,
             lon,
             lat,
             speed,
             direction,
             odometer,
             statusstr,
             placeroad,
             created_date,
             CREATED_BY)
          VALUES
            (P_CAR_NUM,
             P_GPSTIME,
             P_LON,
             P_LAT,
             P_SPEED,
             P_DIRECTION,
             P_ODOMETER,
             P_STATUSSTR,
             P_PLACEROAD,
             SYSDATE,
             1);
          P_STATE := 0;
          P_MSG   := SUBSTRB('line:' || dbms_utility.format_error_backtrace() ||
                             ' Occur error;' || SQLCODE || ',' || SQLERRM,
                             1,
                             200);
          COMMIT;
        WHEN OTHERS THEN
          ROLLBACK;
          P_STATE := 0;
          P_MSG   := SUBSTRB('line:' || dbms_utility.format_error_backtrace() ||
                             ' Occur error;' || SQLCODE || ',' || SQLERRM,
                             1,
                             200);

    显示结果:

    ine:ORA-06512: 在 "employeDB.__DATA_SYNC", line 512
    Occur error;-12899,ORA-12899: 列 "EMS"."T_ISDT_ELOCKAUTOREQUEST"."WID" 的值太大 (实际值: 137, 最大值: 50)

    搏击长空
  • 相关阅读:
    memcached全面剖析
    Zabbix中文使用手册
    lombok
    guava cache
    linux 文件检索操作
    mysql慢查询
    碎片脚本注解(后续整理)
    Docker 目录挂载详述
    jenkins 添加 sonraqube java&vue项目记录
    Ansible unarchive模块
  • 原文地址:https://www.cnblogs.com/yitong/p/6538730.html
Copyright © 2020-2023  润新知