首页 > 数据库 > Oracle > 正文

Oracle中调试存储过程

2024-08-29 13:30:49
字体:
来源:转载
供稿:网友
国内最大的酷站演示中心!

本人在写存储过程时,不知道如何调试它。 有一种调试办法就是在程序中打印出变量的值,在java中俺是打印在控制台上的。以下告诉众位如何从在sqlplus上实现。

1、sqlplus 上执行 “set serveroptput on”命令

2、在存储过程中可以用  dbms_output.put_line(varname); 来打印出来

给个存储过程的例子:

create or replace procedure test is

 emp_name    varchar2(10);
   cursor      c1 is select ename from emp
                  where deptno = 20;
begin
   open c1;
   loop
      fetch c1 into emp_name;
      exit when c1%notfound;
      dbms_output.put_line(emp_name);
   end loop;

end test;

 

后台建立test这个存储过程,编译它,以scott/tiger帐号进入,执行set serveroptput on,然后执行“exec test”
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表