PL/SQL带参数的过程小例子:
in 参数:读入参数,主程序向过程传递参数值;
out参数:读出参数,过程向主程序传递参数值;
in out参数:双向参数.主程序与过程双向交流数据;
sql 代码
- Set serveroutput on
- create or replace procedure scott.tempprocedure(
- tempdeptno in scott.dept.deptno%type,
- tempdname out scott.dept.dname%type,
- temploc in out scott.dept.loc%type)as
- loc1 scott.dept.loc%type;
- dname1 scott.dept.dname%type;
- begin
- select loc into loc1
- from scott.dept
- where deptno=tempdeptno;
- select dname into dname1
- from scott.dept
- where deptno=tempdeptno;
- temploc:='地址:'||loc1;
- tempdname:='姓名'||dname1;
- end;
主程序调用代码:
sql 代码
- set serveroutput on
- declare
- myno scott.dept.deptno%type;
- mydname scott.dept.dname%type;
- myloc scott.dept.loc%type;
- begin
- myno:=10;
- mydname:='崔映辉';
- myloc:='上海信息产业集团';
- scott.tempprocedure(myno,mydname,myloc);
- dbms_output.put_line(myno);
- dbms_output.put_line(mydname);
- dbms_output.put_line(myloc);
- end;
95

被折叠的 条评论
为什么被折叠?



