Categories

Sometimes there are certain actions that need to be performed before an XML report is produced. Or certain actions have to be performed after an XML report has run (updating values in a table, kicking off the bursting engine, etc).

In the past these kind of actions were accomplished by using beforeReport and afterReport triggers in the Oracle Reports report. With the rise of XML publisher as the recommended way for producing reports it may seem that this triggers are gone.

Fortunately this is not the case. There's still the option of using beforeReport and afterReport triggers, even if you're only using an XML template to define the XML publisher report.The trick is to create an XML data template which calls the triggers. The following example does exactly this.

<dataTemplatename="D_EXAMPLE1"description="Example of before and after trigger"

defaultPackage="xxpvz_reporting*">

<parameters/>

<dataQuery>

<sqlStatementname="Q1">

<![CDATA[ select 1 field1 from dual

]]>

</sqlStatement>

</dataQuery>

<dataTriggername="beforeReport"source="xxpvz_reporting.init()"/>

<dataStructure>

<groupname="G_EXAMPLE"source="Q1">

<elementname="FIELD1"value="FIELD1"/>

</group>

</dataStructure>

<dataTriggername="afterReport"source="xxpvz_reporting.post()"/>

</dataTemplate></p><p>

The functions called in the dataTrigger sections need to return a Boolean value. When true is returned XML publisher "knows" all went well with the trigger. However when you return false XML Publisher will detect the trigger reported an error and will not continue. The concurrent program will get into an error state and the report will not be generated.

The example code below will start the bursting engine for the current report.