scott中
2.创建一个过程,修改DEPT中的某一单位的单位名称,过程应包括异常处理;create or replace procedure 
up_dept(s1_deptno dept.deptno%type,s1_dname dept.dname%type)
as begin
update dept set dname=s1_dname where deptno=s1_deptno;
exception
  when no_data_found then
    dbms_output.put_line('没有该部门数据');
    end up_dept;无论输什么数据,异常都抛不出来

解决方案 »

  1.   

    no_data_found 应该只会在select into才产生
      

  2.   

    可以分步的调试一下了,具体用的开发环境最好用sql developer可以调试,在sqlplus中是否报错。
      

  3.   

    首先,你输入的数值不会产生no_data_found异常。
    其次你要想如果部门不存在,报异常。
    你可以在update前面 家
    select dname into 自己定义一个变量  from dept  t where deptno=s1_deptno;
    如果此时部门不存在 就会跳到异常处理
      

  4.   

    NO_DATA_FOUND异常是引发时机是:
    1. 下标索引指向一个被删除的元素,或是关联数组中不存在的元素
    2. 一个select into语句没有检索到数据所以,你的语句不会引发NO_DATA_FOUND异常,是正常的。
      

  5.   

    create or replace procedure 
    up_dept(s1_deptno dept.deptno%type,s1_dname dept.dname%type)
    as begin
    update dept set dname=s1_dname where deptno=s1_deptno;
    /*exception
      when no_data_found then*/
        if sql%notfound then
      dbms_output.put_line('没有该部门数据');
      end up_dept;