Course Title : Reports 6i
May 24, 2015
Course Title : Reports 6i
Common report styles required in a business report
Various report destinations
Main Report executables
Main components of Report Builder
• Main objects in a report
Different methods of building the report query
• Live Pre-viewer– viewing of a reports output format without printing
it.– It also provides a set of tools to allow the format of
the report to be altered. – These include:
• Precision of numbers
• Left, right and centering of text
• Bold, underline, italic options
• Font type and size
• add dollar signs, change colors etc.
• Add page number and current date to a report– Create a report using the report wizard with no
template.– Display the report in the Pre-Viewer.– Click on the menu option insert
–Click on the date option and select the position of thedate and the format of the date required.–Click on the ‘Page Number’ option and select the page number type and location.
Report Columns• Database columns
– Columns associated with the columns retrieved from the database by the query.
• Summary columns– Summarizes another column and may recalculate for each
group.
• Formula columns– Uses a formula written in PL/SQL to calculate a value from one
or more other columnsExampleFunction salcomm return Number is
BeginReturn(:sal+nvl(:comm,0));
End;
• Placeholder columns– Holds a value that has been calculated and placed into by
formula column.
/* Does this child record compare to the max sal
for the dept ? If yes, and placeholder already
set (i.e. we have more than one max sal) set the
placeholder to the concatenated string. Else
set the placeholder to the employee's name */
if (:sal = :max_dept_sal) then
if (:highest_paid_emp <> ' ') then
:highest_paid_emp := :highest_paid_emp||' and ' ||:ename;
else
:highest_paid_emp := :ename;
end if;
end if;
return (:highest_paid_emp);
end;
Adding ChartsUsing Chart Wizard
Report Runtime Parameter Form
Triggers Categories
• Report triggers– After Parameter Form trigger – After Report trigger – Before Parameter Form trigger – Before Report trigger – Between Pages trigger
• Data triggers– Formula Triggers– Validation Triggers
PL/SQL Editor
• After Parameter Form trigger : ---------------------------------• Example :Build a dynamic where clauseFunction AfterPForm RETURN BOOLEAN ISBEGINif :P_CUSTOMER is NULL then :p_where_clause:= ' ';else :p_where_clause := 'where id >= :p_customer';end if;return(true);end;Query Syntax :-----------------SELECT ID,NAME FROM CUSTOMER &P_WHERE_CLAUSE
ORDER BY NAME
• FORMAT TRIGGER :
--------------------------EXAMPLE : HIDE FIELDS DYNAMICALLY
FORMAT TRIGGER ON SALARY FIELD
FUNCTION PAY_CLERKS_SEE_THIS RETURN BOOLEAN IS
BEGIN
IF STANDARD.USER = 'PAY_CLERK' THEN
RETURN(TRUE);
ELSE
RETURN(FALSE);
END IF;
END;
EXAMPLE : CONDITANALLY SET THE ATTRIBUTES if salary equals 2000.
FORMAT TRIGGER ON FIELD salaryFUNCTION sal_mask RETURN BOOLEAN ISBEGIN
IF :SALARY = 2000 THENSRW.ATTR.MASK :=SRW.WEIGHT_ATTR +
SRW.STYLE_ATTR +SRW.GCOLOR_ATTR +SRW.HJUST_ATTR;
SRW.ATTR.WEIGHT :=SRW.BOLD_WEIGHT;SRW.ATTR.STYLE :=SRW.UNDERLINE_STYLE;SRW.ATTR.GCOLOR := 'MAGENTA';SRW.SET_ATTR(0, SRW.ATTR);
END IF;RETURN(TRUE);END;
format trigger to add an alternating color scheme
•Highlight R_G_CATEGORY node in the Object Navigator•Move the mouse to the Layout Editor without clicking on anything.•Click the Fill Color icon and select the ‘Custom1’ color button•Click the Fill Color icon again, set the ‘Patterns’ option to ‘Transparent’•Click the Line Color icon and set it to ‘No Line’
Managing Report Templates
In a new template under the body node • default node• override node.
The default attributes of a template can be applied to any style of report. E.g. The font of data in a template can be applied to the report, regardless of its style. The override attribute of a template, are attributes which can be applied only to certain styles of reports.
Register a customized template in the predefined template list
– To make file PORT.TDF available in the Reports Wizard, predefined templates list do the following:-
– Search for file CAGPREFS.ORA, this is the reports global preferences file name under windows.
– To the Reports.xxx_Template_Desc list, add the description that you want to appear on the Template page of the Report Wizard.
– To the corresponding Reports.xxx _Template_File list, add the file name of your template in the same position as the addition you made to the description list.
– Copy the template file (filename.tdf) to ORACLE_HOME/REPORT60/ADMIN/TEMPLATE/US.
Sample image of your template in Report Wizard:
– For each report style (tabular, group left, etc.) for which the template is defined, apply the template to a sample report.
– Use a screen capture tool to capture a portion of each sample report (no larger than 2 inches wide and 3 inches high) in .bmp format using the naming convention like yyyz.bmp where
– yyy matches the filename specified in the Reports.xxx_Template_File list
• z identifies the report style:– a Group Above
– f Form-like
– g Matrix with Group
– l Group Left
– m Mailing Label
– r Form Letter
– t Tabular
– X Matrix
– Copy or create the .bmp file you want to use as a default (i.e., displays if no bitmap exists for a specific report style) and name it yyy.bmp.
– Copy each .bmp file to ORACLE_HOME/REPORT60/ADMIN/TEMPLATE/US.
Creating an additional report layout
• Used when different queries need to be placed in different styles. To do this :– In the Layout Model view, click in the tool palette.
– Click and drag a rectangular area for the default layout to display the Report Wizard.
– Follow the wizard to select the data to display in the new layout section.
– To reorder the layout sections, click and drag them to new positions in the Layout Model view.
– Modify the report output in the Live Previewer view, or choose Tools Report Wizard to re-enter the wizard.