ITeye博客

PL/SQL带参数的过程

sprite · 2007-02-26 17:00 · 数据库 · Markdown

PL/SQL带参数的过程小例子:

**in 参数:**读入参数,主程序向过程传递参数值;

**out参数:**读出参数,过程向主程序传递参数值;

**in out参数:**双向参数.主程序与过程双向交流数据;

sql 代码

  1. Set  serveroutput on
  2. create or replace procedure scott.tempprocedure(
  3. tempdeptno in scott.dept.deptno%type,
  4. tempdname out scott.dept.dname%type,
  5. temploc in out scott.dept.loc%type)as
  6. loc1   scott.dept.loc%type;
  7. dname1 scott.dept.dname%type;
  8. begin
  9. select loc  into loc1
  10. from  scott.dept
  11. where  deptno=tempdeptno;
  12. select dname  into dname1
  13. from  scott.dept
  14. where  deptno=tempdeptno;
  15. temploc:='地址:'||loc1;
  16. tempdname:='姓名'||dname1;
  17. end;

主程序调用代码:

sql 代码

  1. set serveroutput on
  2. declare
  3. myno  scott.dept.deptno%type;
  4. mydname  scott.dept.dname%type;
  5. myloc  scott.dept.loc%type;
  6. begin
  7. myno:=10;
  8. mydname:='崔映辉';
  9. myloc:='上海信息产业集团';
  10. scott.tempprocedure(myno,mydname,myloc);
  11. dbms_output.put_line(myno);
  12. dbms_output.put_line(mydname);
  13. dbms_output.put_line(myloc);
  14. end;

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。