ORA-02290: 违反检查约束条件 (XIN.MY)这个错误没有相应的预定义exception,必须用sqlcode来判断:
  ...
  exception
      when dup_val_on_index then
        dbms_output.put_line('error!u want to insert into the data that >200');
      when sql_code=2290 then
        ....
  end;
/

解决方案 »

  1.   

    上面的不对:
      exception
          when dup_val_on_index then
            dbms_output.put_line('error!u want to insert into the data that >200');
          when others then
            if sql_code=2290 then
              .....
            end if;
      end;
      

  2.   

    但是oracle提供了一些预定义的异常:
    cursor_already_open,dup_val_on_index,invalid_number,no_data_found,too_many_rows..
    等,这个例子我是在仿照书上的例子写的,书上怎么把异常捕捉到了
    。是不是使用一个语句要将他们包括进来????