BackPrevious Page Next PageNext

Datasets

Creating a dataset

Managing datasets

When you create data components in a report, datasets are created. A dataset is the set of data built from the result of a query, stored procedure, imported SQL, UDS, HDS or business view, and can optionally have filters applied to it. A dataset built on data resource such as query, stored procedure, imported SQL, UDS, and HDS contains all the DBFields in the data resource, as well as parameters and valid formulas in the catalog data source where the data resource is added; a dataset created from a business view contains only view elements and dynamic resources.

A dataset has a name, which by default is the name of the resource on which it is created. For a page report that is created using query resources, you can view items in a dataset by choosing the Dataset View mode from the toolbar of the Data panel.

Datasets in a page report can be shared by different data components. Having data components in the same page report use an existing dataset whenever possible will have a dramatic effect on the performance of your reports in the runtime environment. This is because each dataset is created by running a query against the database, and that is the most expensive part of running a report in terms of execution time. Even when two datasets are based on the same query JReport will still run the query separately for each dataset.

Creating a dataset

To create a dataset, take any of the following ways:

Note: If a dataset is created on a hierarchical data source, when you use the dataset to create data components, pay attention to the unique features of HDS.

Managing datasets

After you have created datasets in a report, you can manage them using the Manage Datasets dialog, for example, you can filter the datasets. To display the dialog, click Report > Manage Datasets.

Manage Datasets dialog

Adding/Removing data fields in a dataset

For any dataset, JReport automatically adds fields to it when fields are added to the data components that use the dataset, and removes the fields from the dataset once you remove them from the data components that use it. So there generally is no need to ever add or remove fields from a dataset specifically. However, in the Manage Datasets dialog, you can still manually add or remove data fields from a dataset.

  1. In the Dataset List box of the Manage Datasets dialog, select the dataset you want to edit.
  2. In the Data tab of the dialog:
  3. When done, click OK to apply the changes and close the dialog box.

Filtering data fields in a dataset

  1. In the Dataset List box of the Manage Datasets dialog, select the dataset with the data fields you want to filter, then click the Filter tab.
  2. If the dataset is created on a business view, the Filter drop-down list is available, listing all the predefined filters of the business view. You can select one from the drop-down list to apply to the dataset, or select User Defined in the list to define a new filter as required.
  3. Click the Add Condition button to add a condition line.
  4. In the field drop-down list, specify the field on which the filter will be based.

    For a dataset created on a query, stored procedure, imported SQL, UDS, or HDS, you can filter on any DBField in the data resource, or a parameter or valid formula that is in the same catalog data source as the data resource. For a dataset created on a business view, you can only filter on a group or detail object in the business view.

  5. From the operator drop-down list, set the operator with which to compose the filter expression.
  6. In the value text field, click Choose button to specify the value of how to filter the field in the displayed dialog or input the value manually. You can use a DBField or a formula as the value to filter the dataset, or the special field User Name or a parameter to filter the dataset dynamically (for the usage of parameters in filter conditions, see the example in Dynamically Filtering Queries).

    When you type in the value, if multiple values are required, they should be separated with ",", and if "," or "\" is contained in the values, write it as "\," or "\\".

  7. Click Add Condition to add more condition lines and define the logic between the condition lines.

    To group some condition lines, select them and click the Group button, then the selected condition lines will be added in one group and work as one line of filter expression. Conditions and groups together can be further grouped. To take any condition or group in a group out, select it and click Ungroup.

    To adjust the priority of the condition lines, select it and click the Up or Down button.

    To delete a condition line, select it and click the Delete button.

  8. Click OK to save the condition.

Tips:

Note: The following SQL type of data cannot be filtered: Db.SQL_BINARY, Db.SQL_BLOB, Db.SQL_CLOB, Db.SQL_LONGVARCHAR, Db.SQL_LONGVARBINARY, Db.SQL_VARBINARY and Db.SQL_OTHER.

Optimizing a dataset

You can enlarge or decrease the scope of retrieved data for a dataset, and therefore make a balanceable decision between better performance and special usage cases/demands. However, this feature is not supported on datasets created from business views so only works for page reports that are created using query resources. For datasets created on business views, you can make use of the Prefetch property on the business views.

  1. In the Dataset List box of the Manage Datasets dialog, select the dataset with the name you want to optimize.
  2. Click the Optimize Dataset button. The Optimize Dataset dialog appears.

    Optimize Dataset dialog

  3. Choose a retrieved data scope for the dataset.
  4. Click OK to apply the settings and close the dialog.

Creating a dataset

You can create datasets for a page report via the Manage Datasets dialog. To do this:

  1. In the Manage Datasets dialog, click the New button.
  2. In the New Dataset dialog, specify the data source on which the dataset will be built.
  3. Enter the name of the dataset in the New Dataset Name field.
  4. Click OK, and an empty dataset is created.
  5. Add data fields to the dataset as required.

Renaming a dataset

  1. In the Dataset List box of the Manage Datasets dialog, select the dataset with the name you want to modify.
  2. Double-click the Name cell of the dataset.
  3. Input a new name in the cell and press Enter to apply the changes.

    However, you should not rename a dataset that has been used by any data component. Renaming a referenced dataset will cause data components based on the dataset not to work.

Removing a dataset

  1. In the Dataset List box of the Manage Datasets dialog, specify the dataset you want to remove.
  2. Click the Remove button to remove the specified dataset.
  3. When done, click OK to apply the changes and close the dialog.

    However, if you remove a dataset directly in this way, any data components created based on the dataset will not work. So, when you want to remove a dataset, it is recommended that you first remove the data components which reference this dataset.

BackPrevious Page Next PageNext