ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 【Exception】:own error message

【Exception】:own error message

原创 Linux操作系统 作者:yellowlee 时间:2009-04-05 21:04:20 0 删除 编辑

CREATE OR REPLACE PROCEDURE p_test_raise_salary(emp_id NUMBER,
                                                amount NUMBER) AS
  curr_sal varchar2(30);
BEGIN
  SELECT dual.dummy INTO curr_sal FROM dual;
  IF curr_sal IS not NULL THEN
    /* Issue user-defined error message. */
    raise_application_error(-20101, 'Salary is missing');
  ELSE
    dbms_output.put_line('test');
  END IF;
END p_test_raise_salary;

for pro c:

EXEC SQL EXECUTE
/* Execute embedded PL/SQL block using host
variables my_emp_id and my_amount, which were
assigned values in the host environment. */
DECLARE
null_salary EXCEPTION;
/* Map error number returned by raise_application_error
to user-defined exception. */
PRAGMA EXCEPTION_INIT(null_salary, -20101);
BEGIN
raise_salary(:my_emp_id, :my_amount);
EXCEPTION
WHEN null_salary THEN
INSERT INTO emp_audit VALUES (:my_emp_id, ...);
END;
END-EXEC;

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/16179598/viewspace-584816/,如需转载,请注明出处,否则将追究法律责任。

上一篇: 清明
请登录后发表评论 登录
全部评论

注册时间:2008-12-27

  • 博文量
    316
  • 访问量
    658547