|Oracle 8i Data Cartridge Developer's Guide
Release 2 (8.1.6)
Part Number A76937-01
Methods: Using PL/SQL, 6 of 6
One of the simplest ways to debug PL/SQL code is to try each method, block, or statement interactively using SQL*Plus, and fix any problems before proceeding to the next statement. If you need more information on an error message, enter the statement
ERRORS. Also consider displaying statements for runtime debugging, such as those of the general form:
You can debug stored procedures and packages using the
DBMS_OUTPUT package. You insert
PUTLINE statements in your code to output the value of variables and expressions to your terminal. The
DBMS_OUTPUT package is described in the Oracle8i Supplied Packages Reference and the PL/SQL User's Guide and Reference.
To debug stored procedures and packages, though not object type methods at present, you can use Procedure Builder, which is a part of the Oracle Developer/2000 tool set. Procedure Builder lets you execute PL/SQL stored procedures and triggers in a controlled debugging environment, and you can set breakpoints, list the values of variables, and perform other debugging tasks. See the Oracle8i Java Stored Procedures Developer's Guide
A PL/SQL tracing tool provides more information about exception conditions in application code. You can use this tool to trace the execution of server-side PL/SQL statements. Object type methods cannot be traced directly, but you can trace any PL/SQL functions or procedures that a method calls. The tracing tool also provides information about exception conditions in the application code. The trace output is written to the Oracle server trace file.
Only the database administrator has access to this trace file. The tracing tool is described in the Oracle8i Application Developer's Guide - Fundamentals.
If you are a C or C++ programmer, several PL/SQL conventions and requirements may differ from your expectations. Note the following about PL/SQL:
VARRAYsbegin at index 1 (not 0).
IFstatement requires the
IFkeyword (which comes after the
ELSEclause, if there is one).
PRINTFstatement. The comparable feature is the
PUT_LINEstatement. In this statement, literal and variable text is separated using the double vertical bar (||).
This section presents several kinds of errors you may make in creating a data cartridge.
13/19 PLS-00538: subprogram or cursor '<name>' is declared in an object type specification and must be defined in the object type body 15/19 PLS-00539: subprogram '<name>' is declared in an object type body and must be defined in the object type specification
If you see either or both of these messages, you have made an error with the signature for a procedure or function. In other words, you have a mismatch between the function or procedure prototype that you entered in the object specification, and the definition in the object body.
Ensure that parameter orders, parameter spelling (including case), and function returns are identical. Use copy-and-paste to avoid errors in typing.
ORA-28576: lost RPC connection to external procedure agent ORA-06512: at "<name>", line <number> ORA-06512: at "<name>", line <number> ORA-06512: at line 34
This error might occur after you exit the debugger for the DLL. Restart the program outside the debugger.
ERROR at line 1: ORA-04068: existing state of packages has been discarded ORA-04063: package body "<name>" has errors ORA-06508: PL/SQL: could not find program unit being called ORA-06512: at "<name>", line <number> ORA-06512: at line <number>
This error might occur if you are extending an existing data cartridge; it indicates that the package has been corrupted and must be recompiled.
Before you can perform the recompilation, you must delete all tables and object types that depend upon the package that you will be recompiling. To find the dependents on a Windows NT system, use the Oracle Administrator toolbar. Click the Schema button, log in as sys\change_on_install, and find packages and tables that you created. Drop these packages and tables by entering SQL statements of the following form into the SQL*Plus interface:
The recompilation can then be done using a SQL statement of the following form: