Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Fetching dataset value in Master Page footer
gruel
Hi,
I am just starting with BIRT and I need to convert reports done with eReport Designer 8 to BIRT.
For the Body part on the report, it goes well.
But, in our reports done with eReport Designer, we fetched information from the database to show in the Header and the Footer.
First, in the header, we fetch a logo from the database (stored as text) and depending on the company's division, if we found a specific logo, we would display it, otherwise it would be blank.
Second, in the footer, as we use only Oracle Stored Procedures for the retrieval of data, each report has an Oracle Package (named based on the report name) and each Package has a version that we retrieve using the GetPackageVersion function in the package.
Finally, my question is...
How can I retrieve information from the database, using BIRT datasets, in the Header and Footer of the MasterPage ? It is possible ?
I have tried a many things, but with the little BIRT experience I have, I have not yet found a way to do this. I have read a few pages of threads in this forum but have not found what I was looking for.
Can anybody help me ? I would really appreciate your help.
Kind Regards
Guy
Find more posts tagged with
Comments
mwilliams
Hi Guy,
Master pages in BIRT are created just once, so switching images probably won't work. You could use multiple master pages and switch those out for different report elements, but you're probably wanting to make changes even within one table. The using a data element in the master page footer will run into a similar issue. If you're using 2.5.x, you could use a report variable that can be updated within the master page because it works within the auto text items which are the only items updated in a master page. Let me know if you have questions.
gruel
Hello Michael,
thank you for your reply. I kept searching for a while and came up with this.
As mentionned, we use Oracle PLSQL packages with Ref Cursor to store the Selection logic in the Oracle database. We have 1 package per report and one common package for procedures and functions that can be reused.
In a typical report package, we would have:
create or replace package REPORT0001
AS
vPackageVersion VARCHAR2(20) := '1.0.0';
FUNCTION GetPackageVersion RETURN VARCHAR2;
PROCEDURE MAIN (p_criteria1 IN VARCHAR2,
p_criteria2 IN VARCHAR2,
p_cur OUT REPORTCOMMON.CURSOR_TYPE);
END REPORT0001;
create or replace package body REPORT0001 is
FUNCTION GetPackageVersion RETURN VARCHAR2
IS
BEGIN
RETURN vPackageVersion;
END GetPackageVersion;
PROCEDURE MAIN (p_criteria1 IN VARCHAR2,
p_criteria2 IN VARCHAR2,
p_cur OUT REPORTCOMMON.CURSOR_TYPE)
IS
BEGIN
OPEN p_cur FOR SELECT * FROM DUAL;
END MAIN;
end REPORT0001;
And the common package header would look like:
create or replace package REPORTCOMMON
AS
TYPE CURSOR_TYPE IS REF CURSOR;
END REPORTCOMMON;
I added a procedure to retrieve the package version based on a parameter.
so the common package now looks like:
create or replace package REPORTCOMMON
AS
TYPE CURSOR_TYPE IS REF CURSOR;
PROCEDURE GetPackageVersion(p_reportname IN VARCHAR2, p_cur out cursor_type);
END REPORTCOMMON;
create or replace package body REPORTCOMMON is
PROCEDURE GetPackageVersionCur(p_reportname IN VARCHAR2, p_cur out cursor_type))
IS
vSelectStatement VARCHAR(500);
BEGIN
vSelectStatement := 'SELECT ' || P_REPORT_NAME || '.GetPackageVersion() AS PackageVersion from dual';
OPEN P_CUR FOR vSelectStatement;
END GetPackageVersionCur;
END REPORTCOMMON;
For the report design , I use a library which contains the master pages (used by the report and containing the field PackageVersion in the footer) and a dataset. This dataset fetches the version from the Oracle database. The parameter is set in the beforeOpen event and it uses the display name in the report design (not the library)
<oda-data-set extensionID="org.eclipse.birt.report.data.oda.jdbc.SPSelectDataSet" name="DSPackageVersion" id="214">
<property name="eventHandlerClass">MyClass</property>
<list-property name="parameters">
<structure>
<property name="name">p_report_name</property>
<property name="dataType">string</property>
<property name="position">1</property>
<expression name="defaultValue" type="javascript">'BTRAMR0001'</expression>
<property name="isInput">true</property>
<property name="isOutput">false</property>
</structure>
</list-property>
<structure name="cachedMetaData">
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">PACKAGEVERSION</property>
<property name="dataType">string</property>
</structure>
</list-property>
</structure>
<method name="beforeOpen"><![CDATA[
this.setInputParameterValue("p_report_name", reportContext.getDesignHandle().displayName);
</method>
<property name="dataSource">actuateDataSource</property>
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">PACKAGEVERSION</property>
<property name="nativeName">PACKAGEVERSION</property>
<property name="dataType">string</property>
</structure>
</list-property>
<xml-property name="queryText"><![CDATA[{call MAXIMO.BTRAMRCOMMON.GETPACKAGEVERSIONCUR(?)} ]]></xml-property>
</oda-data-set>
So now, at run-time, the parameter is updated with the right reportname and the dataset fetches the information for the package version, by going through the REPORTCOMMON package.
I had tried many other things previously and only that way worked for me.
I haven't had time to look for the solution for the dynamic logo issue yet. I have 14 reports to convert from eReportDesigner to BIRT until December 18th and I have more important issues to resolve (i.e. MaximumHeight of textbox,etc...)
Hoping the explanation is clear and could help someone else.
Kind Regards
Guy