---
title: "PL/SQL带参数的过程"
author: "sprite"
date: "2007-02-26T17:00:04Z"
tags: []
slug: "pl-sql"
draft: false
lastmod: "2007-02-26T17:00:04Z"
id: 55950
url: "https://sprite.iteye.com/blog/55950"
---

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

**in 参数：**读入参数，主程序向过程传递参数值；

**out参数：**读出参数，过程向主程序传递参数值；

**in out参数：**双向参数．主程序与过程双向交流数据；

sql 代码

01. Set  serveroutput on
02. create or replace procedure scott.tempprocedure(
03. tempdeptno in scott.dept.deptno%type,
04. tempdname out scott.dept.dname%type,
05. temploc in out scott.dept.loc%type)as
06. loc1   scott.dept.loc%type;
07. dname1 scott.dept.dname%type;
08. begin
09. 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 代码

01. set serveroutput on
02. declare
03. myno  scott.dept.deptno%type;
04. mydname  scott.dept.dname%type;
05. myloc  scott.dept.loc%type;
06. begin
07. myno:=10;
08. mydname:='崔映辉';
09. 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;