Date post: | 10-Apr-2015 |
Category: |
Documents |
Upload: | hebanoweir |
View: | 2,782 times |
Download: | 3 times |
Prepared by: Eng. Héba M. Noweir
ORACLE REPORTS DEVELOPER 9i:
BUILD INTERNET REPORTS
Oracle Reports Developer 9i: Build Internet Reports
Prepared by: Eng. Héba M. Noweir
• 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 ………………………………………………...
(A) BIND PARAMETERS …………...(B) LEXICAL PARAMETERS ………
6 6 7
SRW, CONDITIONAL FORMATTING, SUMMARY ITEMS 7 BOILER-PLATE TEXT ……………………………………….. 8 TEMPLATES ………………………………………………….. 8 GENERATING XML REPORT ………………………………. 8 OPENING A REPORT FROM A FORM …………………… 9
Oracle Reports Developer 9i: Build Internet Reports
Prepared by: Eng. Héba M. Noweir
1
• 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
Oracle Reports Developer 9i: Build Internet Reports
Prepared by: Eng. Héba M. Noweir
2
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]
Oracle Reports Developer 9i: Build Internet Reports
Prepared by: Eng. Héba M. Noweir
3
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.
Oracle Reports Developer 9i: Build Internet Reports
Prepared by: Eng. Héba M. Noweir
4
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
Oracle Reports Developer 9i: Build Internet Reports
Prepared by: Eng. Héba M. Noweir
5 (4) Matrix Row Fields: Job_id (5) Matrix Column Fields: Department_id (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
COLUMN
CELL
Field
Field
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
Oracle Reports Developer 9i: Build Internet Reports
Prepared by: Eng. Héba M. Noweir
6
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
Oracle Reports Developer 9i: Build Internet Reports
Prepared by: Eng. Héba M. Noweir
7 P_PAR1 Property Inspector
List of Values (Select Statement): SELECT LAST_NAME FROM 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');
Oracle Reports Developer 9i: Build Internet Reports
Prepared by: Eng. Héba M. Noweir
8 return (TRUE); end; 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
Oracle Reports Developer 9i: Build Internet Reports
Prepared by: Eng. Héba M. Noweir
9 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('MyName')+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