Debug stored procedures in Oracle

Source: Internet
Author: User
Tags sqlplus

Source: Network/Editor: getting started with programming: Unknown

I do not know how to debug the stored procedure when writing it. One debugging method is to print the value of the variable in the program. in Java, the value is printed on the console. The following describes how to implement the Code on sqlplus.

1. Run the "set serveroptput on" command on sqlplus.

2. dbms_output.put_line (varname); can be used to print out the stored procedure.

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;

Create the test stored procedure in the background, compile it, enter it with the Scott/tiger account, execute set serveroptput on, and then execute "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.