01.02.2013 Views

Publishing Reports to the Web - Downloads - Oracle

Publishing Reports to the Web - Downloads - Oracle

Publishing Reports to the Web - Downloads - Oracle

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Methodology<br />

Example<br />

The following PL/SQL function can be s<strong>to</strong>red in <strong>the</strong> <strong>Oracle</strong>9i database:<br />

CREATE OR REPLACE FUNCTION CityState (<br />

p_location_id world_cities.location_id%TYPE)<br />

RETURN VARCHAR2 is<br />

v_result VARCHAR2(100);<br />

BEGIN<br />

SELECT city || ‘,‘||state<br />

INTO v_result<br />

FROM world_cities<br />

WHERE location_id = p_location_id;<br />

RETURN v_result;<br />

END CityState;<br />

This function returns <strong>the</strong> city separated by a comma, a space, and <strong>the</strong> state. This<br />

formatting is done at <strong>the</strong> database level and passed back <strong>to</strong> <strong>the</strong> report <strong>to</strong> display.<br />

In <strong>the</strong> report, <strong>the</strong> SQL query would look like:<br />

SELECT location_id, citystate(location_id)"City<br />

& State" FROM world_cities<br />

The result would look like this:<br />

LOCATION_ID CITY & STATE<br />

----------- -------------------------<br />

1 Redwood Shores, California<br />

2 Seattle, Washing<strong>to</strong>n<br />

3 Los Angeles, California<br />

4 New York, New York<br />

20.1.2.4 Redundant Data<br />

A report’s query should ideally select only required columns and not unrequired<br />

columns (redundant query) as this affects performance. The fewer queries you have,<br />

<strong>the</strong> faster your report will run. Single-query data models execute more quickly than<br />

multi-query data models. However, situations can arise where a report not only needs<br />

<strong>to</strong> produce a different format for different users, but also needs <strong>to</strong> utilize different<br />

query statements. Although this can be achieved by producing two different reports, it<br />

may be desirable <strong>to</strong> have a single report for easier maintenance. In this instance, <strong>the</strong><br />

redundant queries should be disabled using <strong>the</strong> SRW.SET_MAXROW() built-in<br />

procedure.<br />

Example<br />

The following code used in <strong>the</strong> Before Report trigger will disable, ei<strong>the</strong>r Query_Emp or<br />

Query_Dept, depending on <strong>the</strong> user parameter:<br />

IF :Parameter_1 = 'A' <strong>the</strong>n<br />

SRW.SET_MAXROW('Query_Emp',0);<br />

ELSE<br />

SRW.SET_MAXROW('Query_Dept',0);<br />

END IF;<br />

20-10 <strong>Oracle</strong> Application Server <strong>Reports</strong> Services <strong>Publishing</strong> <strong>Reports</strong> <strong>to</strong> <strong>the</strong> <strong>Web</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!