Creating a query

To create a query in a catalog, follow the steps below:

  1. In JReport Designer, open the required catalog, then do either of the following:
  2. In the Input Query Name dialog, give a name for the query and click OK. The Query Editor window appears. See the window.
  3. On the Query menu, click Add Table/View/Query to add data to the query. If the catalog data source is connected with multiple connections, you can mash-up multiple data resources in the query that come from all these connections, including tables, views, synonyms, queries, imported SQLs, stored procedures and user defined data sources. When a query, imported SQL, stored procedure or user defined data source is added, it will be added as a single table with all of its columns.
  4. Select the required columns in each table. To select all, click *. The columns will be displayed in the criteria panel of the Query Editor.

    For tables in query of a MongoDB connection, you cannot select all columns by clicking *. The PrimaryKey and ForeignKey columns in each table cannot be selected to a query.

  5. Join the tables as required.

    Based on the Auto Join options that are selected in the Query Editor category of the Options dialog, JReport will join the tables automatically. However, if the pre-join feature is enabled for the data source where the query is created, the auto join settings will not take effect, instead, JReport applies the pre-joins to the added tables. You can also add more joins among these tables.

  6. Create filters on the query.
  7. Add some computed columns and formula fields to the query if required.
  8. Select Apply from the Query menu to save the query.

When a query has been added to a catalog, you can further edit it to suit your requirements.

Note: Normally, a query returns all the records that match its search criteria without considering whether there are duplicated ones. You can decide to get only one copy for each record by checking Select Distinct on the Query menu. When this option is enabled, SQL SELECT statements are treated as SELECT DISTINCT statements. The query will search for identical records and ensures to return them only once instead of returning duplicate records from the database. However, this feature is only supported on queries built in JDBC connections.