Oracle Reports Tutorial 10g (9.0.4) Part Number B10612-01 |
|
Estimated completion time: 15 minutes
Suppose you need to create a Web report that displays salary information about each employee in a department for your company's human resources managers. You already have an HTML page that match the company's logo and colors, and just want to add the necessary information.
This chapter shows you how to use the Data Wizard in Reports Builder to add data to an existing HTML page. At the end of the chapter, you will have created a data model to make data available for use in a Web report.
Text description of the illustration adddata_xg.gif
The steps in this section show you how to open the Web page template we've provided, called emprev.htm
. First, you will open the Web page in your Web browser so you can see what our template looks like.
Note: If you do not have this file, refer to the "Prerequisites" section, in the Welcome chapter. |
emprev.htm
.
Note:
If you are using UNIX, navigate to the directory where Reports Builder is installed, then execute |
d:\Reports_Tutorial
.
emprev.htm
, then click Open.
The Object Navigator now displays the emprev report.
Text description of the illustration adddata_on.gif
When you build a report, you must first build a data model by selecting the data that you want to use in the report.
The steps in this section show you how to use the Data Wizard to build a data model for your Web report. The data model you create makes the data from the sample schema available for you to use in your report.
Text description of the illustration adddata_qb.gif
The EMPLOYEES table displays in the Query Builder as EMPLOYEES and EMPLOYEES A1. The link between the MANAGER ID in EMPLOYEES and the EMPLOYEE ID in EMPLOYEES A1 is automatically created because of the constraints that exist in the EMPLOYEES table.
SELECT ALL EMPLOYEES.EMPLOYEE_ID , EMPLOYEES.FIRST_NAME,EMPLOYEES.LAST_NAME , EMPLOYEES.HIRE_DATE , EMPLOYEES.SALARY , EMPLOYEES.DEPARTMENT_ID , EMPLOYEES_A1.EMPLOYEE_ID , EMPLOYEES_A1.JOB_ID , EMPLOYEES_A1.FIRST_NAME, EMPLOYEES_A1.LAST_NAME FROM EMPLOYEES, EMPLOYEES EMPLOYEES_A1 WHERE (EMPLOYEES.MANAGER_ID = EMPLOYEES_A1.EMPLOYEE_ID)
SELECT ALL EMPLOYEES.EMPLOYEE_ID
, EMPLOYEES.FIRST_NAME,EMPLOYEES.LAST_NAME
, EMPLOYEES.HIRE_DATE
, EMPLOYEES.SALARY
, EMPLOYEES.DEPARTMENT_ID
, EMPLOYEES_A1.EMPLOYEE_ID
, EMPLOYEES_A1.JOB_ID
, EMPLOYEES_A1.FIRST_NAME, EMPLOYEES_A1.LAST_NAME
FROM EMPLOYEES, EMPLOYEES EMPLOYEES_A1
WHERE (EMPLOYEES.MANAGER_ID = EMPLOYEES_A1.EMPLOYEE_ID)
AND EMPLOYEES.DEPARTMENT_ID=100
Concatenate the EMPLOYEES.FIRST_NAME and EMPLOYEES.LAST_NAME fields into one alias called emp_name.
The line of the query should now look like this:
, EMPLOYEES.LAST_NAME ||', '|| EMPLOYEES.FIRST_NAME emp_name
mgr_name
.
The line of the query should now look like this:
, EMPLOYEES_A1.LAST_NAME ||', '|| EMPLOYEES_A1.FIRST_NAME mgr_name
SELECT ALL EMPLOYEES.EMPLOYEE_ID,
EMPLOYEES.LAST_NAME||','|| EMPLOYEES.FIRST_NAME emp_name, EMPLOYEES.HIRE_DATE, EMPLOYEES.JOB_ID, EMPLOYEES.SALARY, EMPLOYEES.DEPARTMENT_ID, EMPLOYEES_A1.EMPLOYEE_ID, EMPLOYEES_A1.LAST_NAME||','|| EMPLOYEES_A1.FIRST_NAME mgr_name FROM EMPLOYEES, EMPLOYEES EMPLOYEES_A1
WHERE (EMPLOYEES.MANAGER_ID = EMPLOYEES_A1.EMPLOYEE_ID) AND EMPLOYEES.DEPARTMENT_ID = 100
On the Groups page, in the left column, click the MGR_NAME field, click the right arrow to move the field to the Group Fields list, then click Next.
On the Totals page, in the left column, click SALARY, then click Sum to display the sum of the Salary column in the Totals list.
Text description of the illustration adddata_dm.gif
In Reports Builder, you can save your report using several formats. Since we're creating a JSP-based Web report, we will save our report as a JSP (JavaServer Page).
emprev_<your initials>
, and change the type to Reports JSP (.jsp), then click Save.
Congratulations! You have now created a data model that will allow you to include a report on your Web page. You now know how to:
To review your work, continue to Chapter 3, "Reviewing the Source Code of the Web Report". Otherwise, skip to Chapter 4, "Creating a Report Block for the Web Report" to continue building your report.
For more information on using the Report Wizard, columns, groups, and fields, see the Reports Builder online help. You can also find more information about why JavaServer Pages are useful by visiting Getting Started with Oracle Reports on the Oracle Technology Network (http://otn.oracle.com/products/reports/
).
|
![]() Copyright © 2002, 2003 Oracle Corporation. All Rights Reserved. |
|