Query tool

Use this function to create inquiry screens that display the results of database requests. It operates by temporarily extracting data into a table and then running a query on that table. The query can then be done at multiple levels of detail, defined by successive page breaks.

The structure of this temporary table enables each user to keep the results of their last query, unless it is a shared query. Using this functionality involves 3 different phases:

  • Defining the query using this function.

  • Executing the query by clicking the Run button.
  • Reviewing the query results if the query has already been executed.

To define a query, you need to provide:

  • A list of fields from database tables.

  • Expressions that can be applied to these fields.

  • Constants and additional expressions.

Joins between tables are automatically determined from the data dictionary, but you can explicitly define them in the Advanced tab.

Additionally, 2 complementary functions are available:

  • The Graphical query function (GESALT), offering similar features through a graphical interface.

  • The SQL query function (GESALQ), which uses the same inquiry screens but is designed for creating SQL-based queries.

Prerequisites

Refer to the implementation documentation.

Screen management

The screen is defined in 5 tabs:

You can edit your query across multiple tabs, but only the first one is mandatory.

The header provides information to identify the query, along with general configuration settings.

Fields tab

This tab allows you to define the information to be printed using a grid layout. Within this grid, you specify:

  • The database table where the data originates

  • The fields or expressions to extract

  • The criteria for totals and breaks

Based on the information provided in the grid, the query designer automatically generates a query, using default join conditions between related tables.

In straightforward cases, this setup is sufficient, and there is no need to configure the following tab.

Advanced tab

This tab is optional. It allows you to define:

  • Presentation criteria (such as page numbering and report layout)

  • Additional selection criteria

  • Specific join conditions

Join conditions are useful in two cases:

  1. When the automatic join algorithm fails.

    • This is easy to identify because an error message displays when validating the query.

    • Often, adding a link to one of the tables not described in the dictionary resolves the issue. Other links remain automatic.

  2. When the automatic join does not match the expected logic.

    • In complex cases, multiple links can exist between tables, but the algorithm stops at the first one it finds.

    • To verify the join, use the Info > Links action button, which displays the details of the detected links.

Access tab

Use this tab to define the access conditions to the query and the extracted data.

Graph tab

You can edit this tab only if a graphical representation is available for the query. It allows you to define how the data displays in the chart.

Specific buttons

This function defines the logic for navigating through the tables to be used, based on the selected tables and the implicit links from the dictionary.

An information box displays the name of the main table and the list of links used to access the other tables specified in the request.

Error messages

Other than the generic messages, the following error messages can appear when entering data:

There must be at least one line.

There are no lines in the requests grid.

Too many sort criteria

The request exceeds the allowed limits. The number of sort criteria cannot exceed 8.

Too many ranges

The request exceeds the allowed limits. The number of ranges cannot exceed 10.

Too many totals

The request exceeds the allowed limits. The number of totals cannot exceed 10.

Table not defined

A calculation formula was used in an expression that references fields from a table that is not linked.

xxx: Non-existent table

The table does not exist in the dictionary.

yyy: Non-existent field

The field does not exist in the dictionary.

Incorrect index

A field is indexed with a value that exceeds its dimension.

Impossible links

The links between the tables could not be established from the dictionary. This can indicate an error in the request, or you might need to explicitly define the links in detail under the Advanced tab.

Tables used

Refer to the implementation documentation.