Oracle9i OLAP Services Developer's Guide to the OLAP DML Release 1 (9.0.1) Part Number A86720-01 |
|
Debugging Programs, 3 of 6
If your program contains an error in logic, then the program might execute without producing an error message, but it will execute the wrong set of commands or produce 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 will execute the commands you specified, but it will do 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 simplified syntax of the DBGOUTFILE command is shown below.
DBGOUTFILE {EOF|[APPEND] file-id [NOCACHE]}
The EOF keyword specifies that the current debugging file should be closed, and that debugging output should no longer be sent to a file.
The APPEND keyword specifies that the output should be added to the end of an existing disk file. If you omit this argument and a file exists with the specified name, then the new output replaces the current contents of the file.
The argument file-id specifies the name of the file to receive the debugging output.
The NOCACHE keyword causes the OLAP DML to write to the debugging file each time it executes a line of code. Without this keyword, file I/O activity is reduced by saving text and writing it periodically to the file.
For the complete syntax of the DBGOUTFILE command, see the entry for the command in OLAP DML Reference, which you can access by selecting Language from the Help menu in OLAP Worksheet.
Using 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.
As outlined below, using either the ECHOPROMPT or IFCOPY option, you can also specify that additional information should be included in the debugging file.
For the syntax of the ECHOPROMPT, IFCOPY, and PRGTRACE options, see the entry for each option in OLAP DML Reference.
The following commands create a useful debugging file called debug.txt
in the current working directory.
prgtrace = yes echoprompt = yes dbgoutfile 'debug.txt'
After executing these commands, you can run your program as usual. To close the debugging file, execute this command.
dbgoutfile eof
In the following sample program, the first LIMIT command has a syntax error.
DEFINE ERROR_TRAP PROGRAM PROGRAM trap on traplabel limit month to first badarg limit product to first 3 limit district to first 3 report sales traplabel: signal errorname errortext END
With PRGTRACE and ECHOPROMPT both set to YES and with DBGOUTFILE set to send debugging output to a file called debug.txt
, the following text should be sent to the debug.txt
file when you execute the ERROR_TRAP program.
(PRG= ERROR_TRAP) (PRG= ERROR_TRAP) trap on traplabel (PRG= ERROR_TRAP) (PRG: ERROR_TRAP) limit month to first badarg ERROR: BADARG does not exist in any attached database. (PRG= ERROR_TRAP) traplabel: (PRG= ERROR_TRAP) signal errorname errortext ERROR: BADARG does not exist in any attached database.
For more information, see the following table.
IF you want documentation about . . . | THEN see . . . |
---|---|
specifying the file to use for output, |
|
individual OLAP DML commands, |
the entry for the command in OLAP DML Reference |
|
Copyright © 1996-2001, Oracle Corporation. All Rights Reserved. |
|