Supplementing WHERE Portions
Logi JReport allows you to change a query at runtime using the API. To do this, you can call the method setWherePortion() from your Java application. However, by calling this method, the original WHERE portion of the query will be replaced. If you want to append the runtime WHERE portion to the original one instead of replacing it/them, you can do it in the following way without using the Java API:
- Open the catalog file SampleReports.cat in
<install_root>\Demo\Reports\SampleReports
. - In the Catalog Manager, expand the desired data source and create a type-in parameter named p_Portion of String type (leave the other settings to their default).
- In the same data source, create a query CustomersInfo on the table Customers. Select all the fields contained in the table.
- Create a page report with a table in it based on the query, and have the fields Customer ID, Customer Name, City and Phone displayed in the report, then apply the Commercial style.
- In the Data panel, right-click the node that represents the query, and then select Edit Query from the shortcut menu.
- In the Query Editor, select Menu > Query > Filter.
- In the Search Condition dialog, add two condition lines (WHERE portions) for the query as follows (for details, see Filtering with the Filter Format):
The colon is used to append the parameter value (of String type) to the first condition line instead of replacing it.
- Select OK to apply the change to the query.
- View the report, and in the Enter Parameter Values dialog, write a WHERE portion in standard SQL syntax as value of p_Portion, for example, CUSTOMERID<20. Then, both of the two WHERE portions will be used to filter the query.