Reports |
A report can arrange and format the data according to your instructions and display the output on the screen, send it to a printer, or store it as a file for future use.
To implement a report, a program must include two distinct components:
The report driver retrieves the specified rows from a database, stores their values in program variables, and sends these - one input record at a time - to the report routine. After the last input record is received and formatted, the runtime system calculates any aggregate values based on all the data and sends the entire report to some output device.
Figure 1. Report driver and database cursor
By separating the two tasks of data retrieval and data formatting, the runtime system simplifies the production of recurrent reports and makes it easy to apply the same report format to different data sets.
The report engine supports the following features:
The report engine supports one-pass reports and two-pass reports. The one-pass requires sorted data to be produced by the report driver in order to handle row grouping with the BEFORE GROUP / AFTER GROUP blocks. The two-pass record handles sort automatically and does not need sorted data from the report driver. During the first pass, the report engine sorts the data and stores the sorted values in a temporary file in the database. During the second pass, it calculates any aggregate values and produces output from data in the temporary files.