Run-Dry Set calculation report using scripts to implement dynamic SQL delivery

Source: Internet
Author: User

In most cases, the data source SQL for the report is fixed, but sometimes it is necessary to dynamically make certain parts of it dynamically, such as allowing the user to query the report data that they care about by selecting tables and fields in the report application, and when the report is developing, you want to use the same template for the same kind of report (detail or summary). At this point you need to receive the corresponding parameters in the report stitching out dynamic SQL to query the production of dynamic reports.

Unlike the general reporting tools that need to be implemented in third-party programs (such as Java), the built-in scripts (datasets) are provided in the run-dry set of reports, which can be done quickly, as illustrated below.

In a class of reports, when a user specifies a table and column, some columns are required, even if the user does not have a selection, and is still displayed after the query. So you need to be in the stitching of SQL in advance to determine whether the required column in the user's chosen column, if not, then add, and also to ensure that the user to select the order of the column.

For example, the order ID, order date, shipping date, arrival date are required fields, and the script is completed using the following steps.

Set Report Parameters

The table name, field name, and query criteria are passed to the report in the specified parameter format, so the report parameter is set as follows:


where columns value: The name of the shipper, shippers, freight charges;

conditions Value: Where order date >= ' 1996-01-01 ' and order date <= ' 1996-12-31 '

set up datasets

Script data sets are used to script SQL stitching and fetching, and the result set is returned.

using a set-up script allows you to step through the calculation logic, and because of its good support for set operations, it is easy to make all the query fields in A2 with the selected field collection and the required set of fields. which

A1: A collection of all required fields;

A2: Sets the collection of fields selected by the user with the set of required fields to ensure that all required fields are selected;

A3-A4: Performs the concatenation good SQL to fetch the number;

A5: Returns a result set for the report.

Edit a report expression

Dynamic column functions are required because report columns are dynamic and cannot be pre-crafted for fixed-column reports.

Dynamic column reports are implemented using the Ds.fname () and Ds.field () functions, which can be used to refer to a set of report related documents. Finally, the auxiliary column A and the first row are hidden to complete the report production.


Run-Dry Set calculation report using scripts to implement dynamic SQL delivery

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.