Use scripts to implement dynamic data sources for reports and dynamic data sources for reports
Some reports in the report system often need to connect different data sources according to the conditions to complete report presentation. This kind of switch between different data sources is called a dynamic data source. Generally, report tools often rely on third-party programs (such as JAVA) to implement dynamic data sources. You can use a built-in script to run dry set computing reports. In this article, we will use an example to understand the implementation process.
Report description
In student information, the data source connected to the report is controlled through parameters. If the status parameter is 1, data source 1 (dev_1) is connected. Otherwise, data source 2 (dev_2) is connected, and the total score of students is summarized by class.
In a set computing report, you can use the set computing script to determine parameters and connect different data sources. Then, use the result set returned by the script in the report template, just like using a data source. The procedure is as follows:
Edit a Report Template
Create two data sources (dev_1 and dev_2) for report development.
Use the report designer to create a report template and set report parameters, datasets, and report expressions.
Set Report Parameters
Status is used to control the connected data source. The default value is 1, and dev_1 is connected.
Set Dataset
Use the script dataset to determine the connected data source based on the parameters and calculate the number of retrieved data:
In A1, the data source to be connected is determined based on the Report parameters. A2 completes Data Query and the results are returned through A4.
Set a report expression
Edit the report expression, directly use the result set returned by the Set Computing script, and use a simple report expression to complete report creation.
We can see that using the script dataset to complete the dynamic data source connection by simply judging the parameters of the received report, without having to complete it in the Java program, it is simpler and more direct.
For more information about the script dataset, see http://blog.csdn.net/u012388497/article/details/40076481.