Sunteți pe pagina 1din 12

 

ORACLE REPORTS DEVELOPER 9i:


BUILD INTERNET REPORTS
 

   

Prepared by: Eng. Héba M. Noweir 
 
 
Oracle Reports Developer 9i: Build Internet Reports 

• CONTENTS

TOPIC PAGE
TABULAR – WIZARD ………………………………………… 1
GROUP LEFT – WIZARD ……………………………………. 1
GROUP ABOVE – WIZARD …………………………………. 1
TABULAR – MANUAL ………………………………………... 2
MASTER-DETAIL – MANUAL ……………………………… 3
DATALINK – MANUAL ……………………………………….. 3
FORM – WIZARD …………………………………………….. 4
FORM LETTER – WIZARD ………………………………….. 4
MAILING LABEL – WIZARD ………………………………… 4
MAILING LABEL – WIZARD ………………………………… 4
MATRIX – MANUAL ………………………………………….. 5
REPORT WITH IMAGE – MANUAL ………………………... 5
GRAPHS ………………………………………………………. 6
PARAMETERS ………………………………………………... 6
(A) BIND PARAMETERS …………... 6
(B) LEXICAL PARAMETERS ……… 7
SRW, CONDITIONAL FORMATTING, SUMMARY ITEMS 7
BOILER-PLATE TEXT ……………………………………….. 8
TEMPLATES ………………………………………………….. 8
GENERATING XML REPORT ………………………………. 8
OPENING A REPORT FROM A FORM …………………… 9

Prepared by: Eng. Héba M. Noweir 
 
 
Oracle Reports Developer 9i: Build Internet Reports 


• Open Reports Builder

I. TABULAR - WIZARD
(1) Designing: Use the Reports Wizard
(2) Create Web Layout only
(3) Tabular
(4) SQL Query:
SELECT EMPLOYEE_ID, FIRST_NAME || ' ' || LAST_NAME NAME, SALARY,
JOB_ID
FROM EMPLOYEES
WHERE DEPARTMENT_ID= 50
(5) Displayed Fields: [Choose from Available Fields]
(6) Totals: Ex. Count (Employee_id), Sum (Salary),..

Notes:
(1) Save Reports as .rdf file
(2) Static Frame (Fixed): Contains all the Records that are displayed only
one time in the Report like Titles.
(3) Repeating Frame: Contains all the Records that will be repeated in the
Report [Called from tables]

II. GROUP LEFT – WIZARD


(1) Repeat Steps 1 & 2 Æ Group Left
(2) SQL Query:
SELECT DEPARTMENT_ID, FIRST_NAME || ' ' || LAST_NAME NAME, JOB_ID,
SALARY
FROM EMPLOYEES
(3) Group Fields: Department_id
(4) Displayed Fields: [Choose from Available Fields]

III. GROUP ABOVE – WIZARD


(1) Repeat Steps 1 & 2 Æ Group Left
(2) SQL Query:
SELECT DEPARTMENT_NAME,JOB_ID,SALARY
FROM DEPARTMENTS D JOIN EMPLOYEES E
ON (E.DEPARTMENT_ID=D.DEPARTMENT_ID)
(3) Group Fields: Level 1 Æ Department_name
Level 2 Æ Job_id

Prepared by: Eng. Héba M. Noweir 
 
 
Oracle Reports Developer 9i: Build Internet Reports 


¾ TASK: Create a Report displaying Regions Æ Countries
Æ Locations Æ Departments Æ Employees

Group Above
SQL Query:
SELECT REGION_NAME, COUNTRY_NAME,CITY, DEPARTMENT_NAME, FIRST_NAME || ' '
|| LAST_NAME NAME
FROM REGIONS R
JOIN COUNTRIES C ON (R.REGION_ID=C.REGION_ID)
JOIN LOCATIONS L ON (C.COUNTRY_ID=L.COUNTRY_ID)
JOIN DEPARTMENTS D ON (L. LOCATION_ID=D.LOCATION_ID)
JOIN EMPLOYEES E ON (D.DEPARTMENT_ID=E.DEPARTMENT_ID)

IV. TABULAR – MANUAL


(1) Build a new Report Manually
(2) You will enter the Data Model View: Create SQL Query
(3) SQL Query:
SELECT EMPLOYEE_ID, FIRST_NAME || ' ' || LAST_NAME NAME, SALARY,
JOB_ID
FROM EMPLOYEES
(4) Go to Paper Layout view
a. Create a Static Frame
b. Double Click on the Static Frame you’ve just created – opens Property
Inspector
Vertical Elasticity: Expand
c. Put Titles [Emp_id, Name, Job, Salary] in Text items on the Static Frame
d. Examine the Toolbar: Flex Off, Confine Off
e. Create a Repeating Frame inside the Static Frame
f. Double Click on the Repeating Frame you’ve just created – opens Property
Inspector
Vertical Elasticity: Expand
Source: Select the Group
g. Create a Field in the Repeating Frame under each title [This is where the
columns will appear] – Property Inspector
Source: [Select Columns]

Prepared by: Eng. Héba M. Noweir 
 
 
Oracle Reports Developer 9i: Build Internet Reports 


V. MASTER-DETAIL – MANUAL
(1) Create a Report manually
(2) SQL Query:
SELECT DEPARTMENT_NAME, FIRST_NAME || ' ' || LAST_NAME
NAME,JOB_ID, SALARY
FROM EMPLOYEES E JOIN DEPARTMENTS D
ON (E.DEPARTMENT_ID=D.DEPARTMENT_ID)
(3) In Data Model View: Drag & Drop [Name, Job_id, Salary] into another Group
(4) In Paper Layout View: Create the following schema

(5) Choose Sources:


1st Repeating Frame: Department_Group
2nd Repeating Frame: Employees_Group
(6) Create Fields and choose sources

VI. DATALINK – MANUAL


(1) Create a Report manually
(2) SQL Query(1):
SELECT DEPARTMENT_ID, DEPARTMENT_NAME
FROM DEPARTMENTS
(3) SQL Query(2):
SELECT DEPARTMENT_ID, FIRST_NAME || ' ' || LAST_NAME NAME,JOB_ID,
SALARY, EMPLOYEE_ID
FROM EMPLOYEES
(4) In Data Model View:
Create a DataLink between Department_id of Query(1) & Department_id of
Query(2)
(5) In Paper Layout View: Create the following schema
(6) Choose Sources:
1st Repeating Frame: Department_Group
2nd Repeating Frame: Employees_Group
(7) Create Fields and choose sources

Note:
The difference between Data-Link Master-detail is that DataLink acts like an outer
join.

Prepared by: Eng. Héba M. Noweir 
 
 
Oracle Reports Developer 9i: Build Internet Reports 

VII. FORM – WIZARD


(1) Create a Report using Wizard
(2) Create Paper Layout only Æ Form
(3) SQL Query:
SELECT EMPLOYEE_ID, FIRST_NAME || ' ' || LAST_NAME, JOB_ID, SALARY
FROM EMPLOYEES

VIII. FORM LETTER – WIZARD


(1) Create a Report using Wizard
(2) Create Paper Layout only Æ Form Letter
(3) SQL Query:
SELECT FIRST_NAME, LAST_NAME,JOB_ID, DEPARTMENT_ID, SALARY,
SALARY * 1.5 "NEW SALARY"
FROM EMPLOYEES
(4) Form Letter Text:
Dear Mr. / Ms. &<FIRST_NAME> &<LAST_NAME> ,
Thanks to your efforts in department &<DEPARTMENT_ID> as &<JOB_ID> ;
your salary will be raised from &<SALARY> to &<NEW_SALARY_>
(5) You can also insert an image

IX. MAILING LABEL – WIZARD


(1) Create a Report using Wizard
(2) Create Paper Layout only Æ Mailing Label
(3) SQL Query:
SELECT FIRST_NAME || ' ' || LAST_NAME NAME,JOB_ID, DEPARTMENT_ID
FROM EMPLOYEES
(4) Mailing Label Text:
Name: &<NAME>
Department: &<DEPARTMENT_ID>
Job: &<JOB_ID>
(5) Property Inspector:
Print Direction: Across / Down [For Repeating Frames]

X. MATRIX – WIZARD
(1) Create a Report using Wizard
(2) Create Paper Web Layout only Æ Matrix
(3) SQL Query:
SELECT DEPARTMENT_ID, JOB_ID, COUNT(*)
FROM EMPLOYEES
GROUP BY DEPARTMENT_ID, JOB_ID

Prepared by: Eng. Héba M. Noweir 
 
 
Oracle Reports Developer 9i: Build Internet Reports 

(4) Matrix Row Fields: Job_id


(5) Matrix Column Fields: Department_id 5 
(6) Matrix Cell Fields: Count

XI. MATRIX – MANUAL


(1) After creating the Matrix Report using a Wizard;
(2) Go to Data Model:
Put job_id in a group with count, drag count from this group.
Put a Cross-Product on Department_id, Job_id group.
(3) Go to Paper Layout View:
Release (Delete) all Static Frames and titles and leave only the 3 Repeating
Frames as shown:

ROW 
Field
 
COLUMN 
Field
 
CELL
Field
 

(4) This is:


a) Create a Repeating Frame (Across) Æ Column
b) Create a Repeating Frame (Down) Æ Row
c) Select the 2 Frames and Layout-Matrix
d) Create a Repeating Frame at the Intersection
e) Horizontal & Vertical Elasticity: Variable

(5) Save this Matrix Layout as a template to be used when needed

XII. REPORT WITH IMAGE – MANUAL


(1) Create a Report manually
(2) SQL Query:
SELECT EMPLOYEE_ID, LAST_NAME, IMAGE FROM EMP1
(3) In Paper Layout View:
a. Create a Repeating Frame and Choose its source:Emp
b. Print Direction: Down/Across
c. Create 3 Fields and choose their sources
d. In the image fields Æ Property Inspector Æ File Format: Image

Prepared by: Eng. Héba M. Noweir 
 
 
Oracle Reports Developer 9i: Build Internet Reports 

XIII. GRAPHS
(1) Create a Report using Wizard
(2) SQL Query:
SELECT JOB_ID, COUNT (*) FROM EMPLOYEES GROUP BY JOB_ID
(3) From Paper Layout, Right Click Æ Graph Wizard
(4) Choose the Graph Type
(5) X-Axis Categories: Job_id
(6) Y-Axis Categories: Count

XIV. PARAMETERS
(A) BIND PARAMETERS (Where Clause)
Example (1):
(1) Create a Report using Wizard
(2) SQL Query:
SELECT EMPLOYEE_ID, LAST_NAME,SALARY,
DEPARTMENT_ID
FROM EMPLOYEES
WHERE DEPARTMENT_ID=:P_DEPT

Example (2):
(1) Repeat Example (1)
(2) F5: Object Navigator
Æ Data Model Æ User Parameters
Æ P_DEPT Æ Property Inspector
Data Type: Number
List of Values (Select Statement): SELECT DEPARTMENT_ID,
DEPARTMENT_NAME FROM DEPARTMENTS

Example (3):
(1) Repeat Example (1)
(2) SQL Query:
SELECT EMPLOYEE_ID, LAST_NAME,SALARY,
DEPARTMENT_ID
FROM EMPLOYEES
WHERE EMPLOYEE_ID BETWEEN :P_PAR1 AND :P_PAR2
(3) F5: Object Navigator
Æ Data Model Æ User Parameters
Æ P_PAR2 Æ Property Inspector
List of Values (Select Statement): SELECT LAST_NAME FROM
EMPLOYEES ORDER BY EMPLOYEE_ID DESC
(4) F5: Object Navigator
Æ Data Model Æ User Parameters
Prepared by: Eng. Héba M. Noweir 
 
 
Oracle Reports Developer 9i: Build Internet Reports 

Æ P_PAR1 Æ Property Inspector


List of Values (Select Statement): SELECT LAST_NAME FROM 7 
EMPLOYEES

(B) LEXICAL PARAMETERS


Since we could not put a column name or table name in Bind
Parameters, we need Lexical Parameters
(1) Create a Report manually
(2) SQL Query:
SELECT EMPLOYEE_ID, LAST_NAME, SALARY,
DEPARTMENT_ID FROM EMPLOYEES
(3) F5: Object Navigator
Æ Data Model Æ User Parameters Æ Create Parameter P_1
Initial Value: WHERE DEPARTMENT_ID=50
(4) Return to the SQL Query: Append [From Employees &P_1]
Notes:
a. If you opened a trigger on any parameter by mistake, delete it
b. Try Paper Parameter Form
c. NVL(:P_DEPT, DEPARTMENT_ID)

XV. SRW, CONDITIONAL FORMATTING, SUMMARY ITEMS


(1) Create a Report using Wizard
(2) SQL Query:
SELECT EMPLOYEE_ID, LAST_NAME, SALARY FROM EMPLOYEES
(3) Conditional Formatting on Salary Column: Right Click on Column
Æ Conditional Formatting Æ New
IF VALUE OF SALARY IS GREATER THAN 10 000 Æ …
Property Inspector Æ Format Mask

(1) Go to Query
(2) Create a Summary item outside the Query Block [Sum_Sal]
Function: Sum
Source: Salary
(3) Paper Layout Æ Create a Field and Choose Source [Sum_Sal]
(4) Create a new Summary item outside the Query Block [Count_Emp]
Function: Count
Source: Employee_id
(5) Paper Layout Æ Create a Field and Choose Source [Count_Emp]

SRW Built-In Package for Reports


(1) Paper Layout Æ Repeating Frame [Employees] Æ Property Inspector
Format Trigger:
function F_EMPLOYEE_IDFormatTrigger return boolean is
begin
IF MOD(:SERIAL.2)=0
THEN
SRW.SET-BACKGROUND-FILL-COLOR('BLUE');
Prepared by: Eng. Héba M. Noweir 
 
 
Oracle Reports Developer 9i: Build Internet Reports 

return (TRUE);
end; 8 
Note:
Where SERIAL is a Summary Item Type:Count

XVI. BOILER-PLATE TEXT


(1) Create Data-Link
(2) Create a Summary Item (Departments) inside the 1st Query
Source: Employee_id
Function: Count
Reset: Department_id
(3) Go to Paper Layout View:
a) Enlarge the main Static Frame.
b) Put a Text Item on the Repeating Frame (Departments), “No
Employees in this Department”
c) Go to Property Inspector:
Format Trigger
“IF :COUNT_EMP=0
THEN
RETURN (TRUE);
ELSE
RETURN (FALSE);
END IF;”

Note:
RETURN (TRUE) on item = ‫إﻇﻬﺮهﺎ‬
RETURN (FALSE) on item = ‫إﺧﻔﻴﻬﺎ‬

XVII. TEMPLATES
(1) From Object Navigator (F5) Æ Templates
(2) Create a Report based on Template (Choose Template File)
(3) From Toolbar: Edit Margin
(4) Insert Date & Time, etc…

XVIII. GENERATING XML REPORT


(1) Install XML Publisher
(2) Open Reports Builder and Create a Report using Wizard
(3) SQL Query:
SELECT LAST_NAME, JOB_ID, SALARY, DEPARTMENT_ID FROM
EMPLOYEES
(4) From Menu Bar Select Æ File: Generate to File XML
(5) Open MS Word:
Data: Load XML Data
Insert: Table Using Wizard
Save File Æ Template.rtf
(6) Preview: PDF
Prepared by: Eng. Héba M. Noweir 
 
 
Oracle Reports Developer 9i: Build Internet Reports 

Note: On the Repeating Frame Æ F: Start & E: End


XIX. OPENING A REPORT FROM A FORM


(1) Put Report.fmb into the Default Folder MyForms
(2) Examine the When-Button-Pressed Trigger on the Push-Button
------------------------------------RUN REPORT----------------------------------------
v_state := run_report_object('Report_Name',pl_id);
No need for the Parameter Part unless you are going to use Parameters
(3) From Forms Builder Object Navigator: on Report.fmb Æ Create Report
(4) F4 on the Report you’ve just created
Filename: Take the full path of the Report.rdf
Report Server: Write the Report Server name Ex. “MyName”
(5) Run the Reports Server

RUN: rwserver server=MyName

(6) Make Sure that the repserver name in the Trigger is the same:
VC_URL:='/reports/rwservlet/getjobid'||substr(v_state,LENGTH('MyNam
e')+2)||'?server=MyName';
Note:
Repserver must be run for Reports as OC4J for Forms

Prepared by: Eng. Héba M. Noweir 
 
 
System Variables

System.record_status System.block_status System.form_status


Get_Block_Property Get_Record_Property Set_Record_Property
System.Cursor_Block System.Cursor_Record System.Cursor_Value
System.Trigger_Block System.Trigger_Record System.Trigger_Item
Find_Built Ins Name_In

• How to open Forms from Browser?

http://127.0.0.1:8889/forms/frmservlet?
Form = form_name.fmx
Userid = hr/hr@orcl

Formsweb.cfg
[logon]
Form = sign_in_formname.fmx
Userid: hr/hr @ orcl
Colors = blaf
In URL after ?config = logon

Administrator username:ias_admin
Instance Name: OAS
Ias_admin Password: OAS10g

In Reports:
Right Click on the Shortcut
Target: hr/hr @ orcl Æ always connected

Prepared by: Eng. Héba M. Noweir 
 
 

S-ar putea să vă placă și