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"