Skip Headers

Oracle® OLAP DML Reference
10g Release 1 (10.1)

Part Number B10339-02
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Feedback

Go to previous page
Previous
Go to next page
Next
View PDF

5.3 Testing and Debugging Programs

Even when your program compiles cleanly, you must also test the program by running it. Running a program helps you detect errors in commands with ampersand substitution, errors in logic, and errors in any nested programs.

To test a program by running it, use a full set of test data that is typical of the data that the program processes. To confirm that you test all the features of the program, including error-handling mechanisms, run the program several times, using different data and responses. Use test data that:

5.3.1 Error and Debugging Options

A number of options determine how errors are handled and what happens during debugging. These options are listed in Table 5-2, "Error Handling Options" and Table 5-3, "Debugging Options".

Table 5-2 Error Handling Options

Statement Description
ERRNAMES
An option that controls whether the value of the ERRORTEXT option contains the name of the error (that is, the value of the ERRORNAME option) as well as the text of the error message.
ERRORNAME
An option that contains the name of the first error that occurs when you execute a program or when you execute an OLAP DML statement.
ERRORTEXT
An option that contains the text of the first error message that occurs when you execute a program or a statement.
PERMITERROR
An option that determines whether or not an error is signaled on attempted access of a variable for which read or write permission is denied by a PERMIT command.
MODERROR
Specifies the action to be taken when a model equation diverges or a block fails to converge. The possible values are STOP, CONTINUE, and DEBUG.
BADLINE
When a program, model, or input file is executing, an option that controls whether Oracle OLAP records, in the current outfile, the line that caused an error.
INF_STOP_ON_ERROR
An option that specifies the behavior of Oracle OLAP when an error is reached when reading from a file using the INFILE command

Table 5-3 Debugging Options

Statement Description
EXPTRACE
An option that controls whether system DML programs are traced when the PRGTRACE option is set to YES.
PRGTRACE
An option that determines whether each line of a program is recorded in the current outfile or in a debugging file during execution of the program.
MODTRACE
An option that controls whether each equation in a model is recorded in a file during execution of the model.
MODERROR
Specifies the action to be taken when a model equation diverges or a block fails to converge. The possible values are STOP, CONTINUE, and DEBUG.

5.3.2 Generating Diagnostic Messages

Each time you run the program, confirm that the program executes its commands in the correct sequence and that the output is correct. As an aid in analyzing the execution of your program, you can include SHOW commands in the program to produce diagnostic or status messages. Then delete the SHOW commands after your tests are complete.

When you detect or suspect an error in your program or a nested program, you can track down the error by using the debugging techniques that are described in the rest of this section.

5.3.3 Identifying Bad Lines of Code

When you set the BADLINE option to YES, additional information is produced, along with any error message when a bad line of code is encountered. When the error occurs, the error message, the name of the program, and the program line that triggered the error are sent to the current outfile. You can edit the specified program to correct the error and then run the original program. Example 8-22, "Using the BADLINE Option" illustrates using the BADLINE option.

5.3.4 Sending Output to a Debugging File

When your program contains an error in logic, then the program might execute without producing an error message, but it executes the wrong set of commands or produces incorrect results. For example, suppose you write a Boolean expression incorrectly in an IF command (for example, you use NE instead of EQ). The program executes the commands you specified, but it does so under the wrong conditions.

To find an error in program logic, you often need to see the order in which the commands are being executed. One way you can do this is to create a debugging file and then examine the file to diagnose any problems in your programs.

To create a debugging file, you use the DBGOUTFILE command.

The DBGOUTFILE command merely creates a file for debugging. To specify that you want each program line to be sent, as it executes, to the debugging file, set the PRGTRACE option to YES.

When you want the debugging file to interweave the program lines with both the program input and error messages, then set the ECHOPROMPT option to YES.