Reports Aisha AlArfaj
Using Reports Developer • Oracle Reports Developer is a robust tool to help in the creation of database applications. • There are generally a finite number of ways to enter information into the database, there are an infinite number of ways to retrieve it. • It is important to have a firm understanding of Reports Developer and how it can decrease the amount of time it takes to create reports.
Creating Your First Report • Creating a report with Reports Developer is very similar to creating a form with Forms Developer. • In this example, you leverage as many of the built-in wizards as possible to make the task easy. • The welcome dialog for Report Builder (shown in Figure 2.9). • As with Form Builder, you have the option of manually creating a report or using ReportWizard.
FIGURE 2.9 The Report Builder welcome dialog allows you to manually create a report or use the Report Wizard to help you.
Creating your first Report • You can see the title and style definition page, as shown in Figure 2.10. Enter “Reports Demo” as the title for this example. • In the title and style definition page there are various styles of reports with a thumbnail image next to each one of what the completed report will look like. • To help you understand the various types of reports, here are some definitions:
FIGURE 2.10 The Report Wizard allows you to define the title and style of your report.
Types of reports Will be explained more in next lecture. • Tabular • Form-like • Mailing Label • Form Letter • Group Left. • Group Above. • Matrix • Matrix with Group
After entering Report Demo for the title and selecting the Tabular layout style, click the Next button. • You are now asked to enter a SQL statement. • If the report uses more than one table, it is best to use the Query Builder tool. • Because your sample report uses only a table, you manually enter the SQL query as: SELECT * FROM table_name • you are asked to define the columns displayed on the report, as shown in Figure 2.11. • Click on the >> button to select all columns to be displayed. • By selecting one column at a time and pressing the > button, you can control the order in which the columns appear in the report.
FIGURE 2.11 The Report Wizard allows you to specify the columns from the table that will be displayed in the report.
You are asked to calculate totals for any given column. • Although totalimplies addition, you also have the options of averages, maximums, minimums, counts, and percentagetotals. • In the example, it would be nice to see the total salaries for everyone in the company, so click on SAL in the Available Fields list and move it to the Totals list using the Sum > button. • You can specify labels and widths as shown in Figure 2.12.
FIGURE 2.12 The Report Wizard allows you to specify labels on the report that are different than the database column names.
Sometimes the developers at Oracle create the tables without using very descriptive column names. They use shorter name. • Unfortunately, this does not make the report easy to read. • Change some of the labels to be more descriptive. • Then, you are ready to choose a report template. • Several predefined templates are included in Report Builder, or you can create your own. • Then, You can see the congratulations page telling you that the Report Wizard is done asking you questions and is ready to generate your report. • Click on Finish and the report is run and displayed to you as shown in Figure 2.13.
FIGURE 2.13 The Live Previewer window gives you an idea of what your report will look like.
Building Complex Reports • It is rare that the person creating the report is also the person responsible for printing and distributing the report. • Therefore, Oracle has built-in some features to help make reports easy to produce. • As with Forms Developer, Reports Developer has a runtime component if you want to deploy a report using the client/server model. • A common method of running reports in this environment is to have a form call the runtime report engine and execute your report. • You also can have reports run from icons on your desktop.
Creating a Master-Detail Report Using Report Builder • To have a master-detail report use group. • For example, Use Group Left layout. • Then, You can specify the SQL query statement. • Most application developers who have spent much time writing SQL statements will feel comfortable entering the SQL query by hand. • However, using the Query Builder reduces the possibility for mistakes. • After the SQL statement has been created, you have the ability to fine-tune it.
In the Query Builder you will see the dialog asking to specify the tables for the query as shown in Figure 4.1. FIGURE 4.1 The dialog to specify tables used in the query for the report.
You will be using the EMP and DEPT tables for this report. • Select the DEPT table in the dialog and click the Include button. • Do the same for the EMP table, and then click the Close button. • This should add the table definitions to the Query Builder tool as shown in Figure 4.2. • In the Query Builder tool you can see that the relationship between the DEPT and EMP tables is shown with a line from the DEPTNO column in the EMP table pointing back to the DEPTNO column in the DEPT table.
FIGURE 4.2 The DEPT and EMP table definitions in the Query Builder tool.
The Query Builder tool provides you some important visual information about the columns in the tables that you use for the report. • Notice the primary keys DEPTNO and EMPNO are both highlighted with the bold font. • Notice also that there is a data type symbol to the right of each of the column names. EMPNO is a number, as indicated by the icon . ENAME is a character column, as represented by the icon ; and HIREDATE is a date as shown by the icon .
you have the ability to specify the columns that will appear in the report. • Click the check box to the left of each of the column names to have the column appear on the report. • The only column from the DEPT table to display is DNAME. • All the columns except DEPTNO should be displayed from the EMP table. When you are done, click OK.
ORDER OF COLUMNS • The order in which you check the columns is the order in which they will be displayed on your report. • So, if you want the ENAME column to appear before EMPNO, click ENAME first. Don’t worry if you don’t get the order correct. • The Report Wizard allows you to reorder them at a later time.
The Query Builder tool is complete and has filled in the SQL statement that will be used for the report. The SQL query in the Layout Wizard is shown in Figure 4.3. FIGURE 4.3 The SQL statement as completed by the Query Builder.
It is relatively easy to create queries with the Query Builder tool when the database is set up correctly. • After generated SQL statement. • You can now have the option to decide which column will differentiate the groups of employees. • This report uses the Department name or the DNAME column. • Select it and move it to the Group Fields list by using the > button. Now click Next.
Then, you can specify the columns that will be displayed as fields on the report. • After that, You are given the chance to add a predefined formula to your list. • The report specifies salary totals for each of the various departments. • Select SAL from the Available Fields list and then click Sum > to create a salary total in the Totals list, as shown in Figure 4.4.
FIGURE 4.4 Adding salary totals for each of the departments for the report.
You can modify some of the layout characteristics such as labels, heights, and widths. • Then, you can choose a template • Now you are finished with the Report Wizard. • The Report Editor should display the finished result shown in Figure 4.5.
FIGURE 4.5 The Report Editor in Live Previewer view showing the completed report after running the Report Wizard.
Using the Re-entrant Layout Wizard • The report in Figure 4.5 looks a bit wide. There is probably a better layout format that could be used instead. • Ratherthan trying to re-create everything, simply rerun the Report Wizard and choose a different layout. • This can be done by selecting Tools, Report Wizard from the menu.
When you rerun the Report Wizard, you will notice a tab bar appears at the top of the wizard dialog. • The different tabs give you access to the various screens you filled out when first running the wizard. • Because all that needs to be changed is the layout, make sure that the Style tab is selected as shown in Figure 4.6.
FIGURE 4.6 The Style attributes when rerunning the Report Wizard.
Using the Report Editor • you can use the Report Editor to modify the report so that it is easier to read. • The Report Editor can be used to clean up reports. • Although these functions can be taken care of with the Report Wizard, it is generally easier to use the Report Editor because you can see all of the changes interactively.
The Report Editor Toolbar • Some useful tools to help you format the report are found on the toolbars. Figure 4.9 shows the upper toolbar with the name of each tool. Short descriptions of each tool follow the figure. FIGURE 4.9 The upper toolbar.
New open new report • Open Opens an existing report. • Save Saves the current report that you are working on. • Print Prints the current report. • Mail E-mails the current report. • Connect To connect to a database • Cut • Copy • Paste • Undo and redo
Run web layout brings up a web browser with the report within it. • Run paper layout give you the Paper Design view. • Help Invokes the Oracle Developer help system. On Windows, the standard Help system is used. On Unix, the Help system is HTML based.
Data Model Changes the mode of the Report Editor to show the data model. It is helpful to show the table relationships used in the report. This is discussed more in Chapter 9, “More About Reports.” • Web source displays the source code for your JSP-based Web report, including HTML, JSP, and XML tags. • Paper Layout Model Changes the mode of the Report Editor to show an abbreviated model layout for your report. It can be helpful when there are different layouts for a report with lots of rows displayed.
Paper Design The default mode for the Report Editor. It allows you to see how the report will look using live data from the tables. • Paper Parameter Form Brings up a parameter form editor to allow you to create a parameter form for the report.
First Page Goes to the first page of the report. • Previous Page Goes to the previous page of the report. • Next Page Goes to the next page of the report. • Last Page Goes to the last page of the report. • Page Number Description Displays the current page in Live Previewer mode.
From menu bar (insert) You can: • Insert Date and Time Inserts a field on the report that displays the date and time the report was last run. • Insert Page Number Inserts page numbers on the report. • Figure 4.10 shows the lower toolbar with short descriptions. The descriptions are explained following the figure. • FIGURE 4.10 • The lower toolbar.
Font The font name used for any selected text object in the Report Editor. • Font Size The font size used for any selected text object in the Report Editor. • Bold Toggles the font for any selected text object between the bold and nonbold version of the font. It can be used together with the Italic and Underline buttons. • Italic Toggles the font for any selected text object between the italic and nonitalic version of the font. It can be used together with the Bold and Underline buttons. • Underline Toggles an underlining rule underneath any selected text object. It can be used together with the Bold and Italic buttons.
Start Justify Lines up selected objects in the report to begin at the common left border. • CenterJustify Lines up selected objects in the report to the common middle. • End Justify Lines up selected objects in the report to end at the common right border. • Flush Justify Adds appropriate spacing so that selected objects in the report have common left and right borders. • Currency Formats a data field to display as currency (using the currency symbol for the current local). • PercentFormats a data field to display as a percentage including the percent symbol.
Commas Formats a numeric data field to contain commas. • Add Decimal Places Formats a numeric data field to display decimal places. • Remove Decimal Places Removes decimal places from a numeric data fields.
FIGURE 4.11 The sample report you are working on, completed to this point.
The Report Editor Tool Palette • The Report Editor also contains a Tool Palette similar to the one found in the Forms Editor. Because a report is static, or noninteractive, the Tool Palette does not contain as many objects. Figure 4.12 shows the Tool Palette found in the Live Previewer view mode.
FIGURE 4.12 The Tool Palette.
Select This is the default tool. Use it to select the various objects on the report. You can then move, resize, and delete the object. • Magnify Similar to the Zoom In and Zoom Out buttons on the toolbar, except that you can specify the center of the zoom area. To zoom out, hold the Shift key and click on the canvas. • Rectangle Creates a rectangle or square on your report. You can use the rectangle to group database fields and provide a more aesthetically pleasing look. Holding down the Shift key creates a square.
Line Puts a line on your report. • Ellipse Puts ellipses and circles on your report. Holding down the Shift key makes circles. • Arc Used to draw arcs on your report. • Rounded Rectangle Draws a rounded rectangle on your form. Holding down the Shift key creates a square. • Text Used to put static text on your report. • Field Used to put a field on your report. Unlike static text, this information can be dynamic. • Link File Used to create a boilerplate object (static text) on your form using text from a file.
Color Box Shows the different colors chosen for drawn objects. The outer box represents the outline of the object, the inner box represents the fill values, and the T represents the color of the text. • Fill Color Selection Brings up the color palette and allows you to specify the fill color. • Line Color Selection Brings up the color palette and allows you to specify the outline color. • Text Color Selection Brings up the color palette and allows you to specify the text color.
FIGURE 4.13 The report with lines above the department totals.
Using the Object Navigator • Oracle Report Builder includes the Object Navigator tool that is also found in Form Builder. • The Object Navigator allows you to see what objects are currently being worked on and their relationships to other objects on the report. • Figure 4.14 shows the Object Navigator for the report you have been working with.
FIGURE 4.14 The Object Navigator found in Report Builder.