Debug stored Procedures in Oracle

Source: Internet
Author: User
Tags sqlplus

I do not know how to debug a stored procedure when I write it. One way to debug this is to print out the value of a variable in a program that I print on the console in Java. Here's how to do this from the Sqlplus.

1, execute "set serveroptput on" command on Sqlplus

2, in the stored procedure can use Dbms_output. Put_Line (VarName); To print out

Give an example of a stored procedure:

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;

The background creates test this stored procedure, compiles it, takes Scott/tiger account entry, executes set serveroptput on, and executes "exec test"

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.