zoukankan      html  css  js  c++  java
  • oracle plsql存储过程中out模式参数的用法

    在plsql中,存储过程中的out模式的参数可以用来返回数据,相当于函数的返回值。下面是一个小例子。

    沿用上一篇的emp表结构和数据。

    存储过程如下:

    create or replace procedure out_test(v_user   in emp.user_name%type,
                                         v_salary out emp.salary%type,
                                         v_deptno out emp.emp_deptno%type) as
    begin
      select salary, emp_deptno
        into v_salary, v_deptno
        from emp
       where user_name = v_user;
    exception
      when NO_DATA_FOUND then
        dbms_output.put_line('No data found');
      when TOO_MANY_ROWS then
        dbms_output.put_line('Too many rows found');
    end out_test;

    在命令行中调用该存储过程,利用绑定变量

    SQL> var v_user varchar2(20);
    SQL> var v_salary number;
    SQL> var v_deptno number;
    SQL> exec :v_user := 'Lisi';
     
    PL/SQL procedure successfully completed
    v_user
    ---------
    Lisi
     
    SQL> exec out_test(:v_user, :v_salary, :v_deptno);
     
    PL/SQL procedure successfully completed
    v_user
    ---------
    Lisi
    v_salary
    ---------
    11500
    v_deptno
    ---------
    20

    这是在plsql developer下运行的结果,这个工具是一个很好的oracle的可视化编程工具。

  • 相关阅读:
    AS3中的xml
    HTML5 tools, Animation tools Adobe Edge Preview
    重新审视php+mssql
    SVN合并分支,从主干合并到分支
    AIR HTML相关资料[js部分]
    USACO 1.1friday
    H.High String
    POJ 3670 Eating Together
    HDU 1203:I NEED A OFFER!
    CodeForces #1 B. Spreadsheets
  • 原文地址:https://www.cnblogs.com/bejour/p/3375104.html
Copyright © 2011-2022 走看看