如何正对一个客户表进行存储过程?大哥大姐们帮帮我吧,之前我发过帖子,但是都没有详细的,我是想求一个在客户表插入、查询、删除和更新出现的异常处理,如:“你查询的数据不存在”拜托各位啦!

解决方案 »

  1.   

    给你举个插入的例子吧:(例子中INSERT时的异常是插入的列值过大,表中的第一个字段定义varchar2(2),实际插入的是'1234567890',超长了)
    create or replace procedure test_yixl_pro
    as
    err_msg varchar2(255);
    begin
      begin
        insert into test_yixl values('1234567890', '1');
      exception when others then
        err_msg := substr(SQLERRM, 1, 200);
        dbms_output.put_line(err_msg);
      end;
    end;
    执行的结果就是:
    ORA-12899: value too large for column "APPS"."TEST_YIXL"."REC" (actual: 10, maximum: 9)
      

  2.   

    没太看明白。似乎是异常处理的
    例子:declare
        v_emp   emp%rowtype;
    begin
        select * into v_emp from emp where empno = &v_empno;
    exception          -- 异常处理
        when no_data_found then         -- oracle异常
            dbms_output.put_line('未找到数据!');
        when others then
            dbms_output.put_line('!!!!!!');
    end;