zoukankan      html  css  js  c++  java
  • PL/SQL 异常处理

    SQL> set serveroutput on
    SQL> declare
      name varchar2(10);
    begin
      select ename into name from emp where empno = &no;
      dbms_output.put_line(name);
    EXCEPTION
      when NO_DATA_FOUND THEN
        dbms_output.put_line('该雇员不存在');
    end;  2    3    4    5    6    7    8    9 
     10  /
    Enter value for no: 7369
    old   4:   select ename into name from emp where empno = &no;
    new   4:   select ename into name from emp where empno = 7369;
    SMITH

    PL/SQL procedure successfully completed.

    ---------------------------------------------------------------------
    create or replace procedure test_proc2(no number) IS
      name varchar2(10);
    begin
      select ename into name from emp where empno = no;
      dbms_output.put_line(name);
    EXCEPTION
      when NO_DATA_FOUND THEN
        dbms_output.put_line('this employees is not exits');
    end;
        

    SQL> exec test_proc2(7369);
    SMITH

    PL/SQL procedure successfully completed.

    SQL> exec test_proc2(10000);
    this employees is not exits

    PL/SQL procedure successfully completed.

  • 相关阅读:
    Python 异常处理
    Python File(文件) 方法
    python 文件定位
    globals() 和 locals() 函数
    python dir()函数
    python from…import* 语句
    python from…import 语句
    Python 模块
    python 匿名函数
    python 函数参数
  • 原文地址:https://www.cnblogs.com/zhaoyangjian724/p/3797975.html
Copyright © 2011-2022 走看看