Oracle plsql存储过程中out模式参数的用法 您所在的位置:网站首页 oracle调用带有out参数的存储过程 Oracle plsql存储过程中out模式参数的用法

Oracle plsql存储过程中out模式参数的用法

2024-07-01 14:20| 来源: 网络整理| 查看: 265

在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的可视化编程工具。

 

转载自:https://www.cnblogs.com/bejour/p/3375104.html



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有