You are on page 1of 3

Event-Driven Publishing using Database Trigger in Reports 9i/10g [ID 199743.

1]

ë  25-JAN-2011  BULLETIN 


PUBLISHED

"Checked for relevance on 25-Jan-2011"

PURPOSE
-------
Demonstrate the Event-based publishing feature of Reports 9i/10G/10G R2 using
a
database trigger.

NOTE: Please see on OTN, "Oracle Application Server Reports


Services Publishing Reports to the Web 10g Release 2 (10.1.2)",
DocID: B14048-02 (for the Topic "Using Event-Driven Publishing")
for the latest document updates for all versions.

SCOPE & APPLICATION


-------------------
All who want to implement event based publishing of Reports using a
database trigger.

Event-Driven Publishing of Oracle9i Reports


--------------------------------------------
This feature provides the ability to automatically run a report in response
to an event in the database, such as the insertion of a record or the change
of a value.

This feature can either be implemented using a database trigger or advanced


queuing technique. The scope of this document is limited to the use of a
database trigger.

How does it work?


-----------------
The Event-Driven Publishing API is a PL/SQL Package (SRW) that provides
the basic functions required for the development of procedures that respond
to events in the database. The server assigns a unique job_ident record to
every call, useful for tracking the status of the job.

How do I implement?
-------------------
1) Create the PL/SQL API for Event-driven publishing in your database:
Run the script srwAPIins.sql (resides under <9iDSHome>/reports/admin/sql)
as follows:
a) Navigate to the directory <9iDSHome>/reports/admin/sql
(On Windows open command prompt and navigate to the directory.)

b) connect to SQL*Plus from the command prompt and then execute the
script from SQL prompt:
SQL>@srwAPIins.sql

c Y 

c) This script asks for portal username and password. If you want to
secure your Reports Server through portal, provide the portal
username/password. However, you could run this script with any
user who has execute privilege on sys.xmlparser and sys.xmldom
packages. You need not have portal installed in the database.

2) Run srwAPIgrant.sql (resides under <9iDSHome>/reports/admin/sql) to grant


privileges on the varray, object types and the package created by the
srwAPIins.sql script to the user who runs a report. Enter the API objects
owner username/password first(the user who ran srwAPIins.sql) and then
the grantee username/password.

3) Create the following procedure in your database to run your report, for
example, emp.jsp:

create or replace procedure event_driven_report as


myPlist SRW_PARAMLIST;
myIdentSRW.Job_Ident;
BEGIN
myPlist := SRW_PARAMLIST(SRW_PARAMETER('',''));

srw.add_parameter(myPlist,'GATEWAY','http://<server_name>:<port>/reports/rwse
rvlet');
srw.add_parameter(myPlist,'SERVER','myRepserver');
srw.add_parameter(myPlist,'REPORT','d:\work\emp.jsp');
srw.add_parameter(myPlist,'USERID','myuser/mypassword@orcl');

srw.add_parameter(myPlist,'AUTHID','portal_username/portal_password@orcl');
srw.add_parameter(myPlist,'DESTYPE','file');
srw.add_parameter(myPlist,'DESFORMAT','HTMLCSS');
srw.add_parameter(myPlist,'DESNAME','c:\temp\emp.htm');
myIdent := srw.run_report(myPlist);
EXCEPTION
when others then
raise;
END;
/

Note: AUTHID parameter is required when your reports server is secured.

4) Execute the procedure:

SQL>exec event_driven_report;

This will submit the job for execution. You can now check the status of
the job using SHOWJOBS. For example:
http://<server_name>:<port>/reports/rwservlet/showjobs?server=myRepserver

5) In case you face any problems, debugging can be enabled as follows:

SQL>set serverout on
SQL>exec srw.start_debugging;
***********************************************************
* WELCOME TO EVENT-BASED-REPORTING API *
* API-Version : 9i *
* (C) Oracle Corporation, 2000 *

c  

*
* Debugging turned ON *************************************

PL/SQL procedure successfully completed.


SQL>event_driven_report;

Now, you can see the step by step execution of the submitted reports job.

Debugging can be turned off by:

SQL>exec srw.stop_debugging;

6) The procedure event_driven_report can be called from a database trigger:

Create or replace trigger tr_emp after update or insert or delete on emp


for each row
begin
event_driven_report;
end;
/

LIMITATIONS
-----------

1) Event-driven API cannot be used with rwcgi or for running report as jsp.
It works only with 9i Reports servlet.
2) When implemented with database trigger, the latest change in the database
is not reflected in the report because the change is committed only when
the database trigger succeeds without any error and the report query runs
before this commit.

RELATED DOCUMENTS
---------------

Related

Products

Œ ë  > D  T


> D  
 & PLSQL > O  R 
D 

£   

c   


You might also like