手动抛异常
DEMO
---------------------------------------阶段3---------------------------------------------------------------------------------------------- declare v_dept dept%rowtype; begin v_dept.deptno := &deptno; V_dept.dname := '&deptname'; V_dept.loc := '&loc'; if instr(v_dept.dname, ' ') > 0 then raise_application_error(-2100, '部门名称不能包含空格'); else insert into dept values v_dept; end if; end; ---------------------------------------阶段3练习---------------------------------------------------------------------------------------------- declare v_order tb_orders%rowtype; begin v_order.ORDERID := &ORDERID; v_order.SUBSCRIBEDATE := '&SUBSCRIBEDATE'; v_order.PAYMENTDATE := '&PAYMENTDATE'; v_order.custid := &custid; select max(id) into v_order.id from tb_orders; select id into v_order.custid from tb_cust where id = v_order.custid; if v_order.custid != null then raise_application_error(-2100, '客户编号不存在'); else insert into tb_orders values v_order; end if; end;
本文来自博客园,作者:Iven_lin,转载请注明原文链接:https://www.cnblogs.com/ivenlin/p/17061375.html
浙公网安备 33010602011771号