Setup > Usage > Reports > SQL query tool 

The softwares in SAFE X3 technology include a query tool that is used to create inquiry screens from queries expressed in the form of a list of fields obtained from the tables in the database, these tables being linked either by default or by explicitly named links. This approach makes it possible for a user to rapidly create queries without using a specific query language, by having a simple understanding of the tables in the database, knowledge that can be aided by the use of the technical documentation (notably MCD). In addition it provides a user friendly inquiry interface in the multi-column screens with the availability of using a tunnel.

This query tool nevertheless has several limitations, for example with respect to complex queries that cannot be strictly expressed in the form of a list of fields. Thus, for users that have more technical ability and an understanding of the SQL language, this query tool does not easily give the desired results.

It is for this reason that an additional tool has been created, the SQL query tool, which is used to express queries by using classic SQL language. This SQL query tool is only distinguishable from the previous query tool by its setup screen. In fact, the screens created by this query tool are called by the same request execution function as that used by the standard query tool.

This signifies that, like the standard query tool, the SQL query tool functions by the temporary extraction of data from a table (the same as the classic query tool), then by consultation of this table. However, the inquiry can only be carried out on one level, breaks and totals not being possible at this level.

Similarly to the classic query tool, the structure of this temporary table means that each user conserves the results of the last request carried out in it and the use of this functionality includes three different steps:

  • definition of the request by this function, then Validation in order to create the corresponding inquiry screen.
  • launch of the query (either using the button, or by using the interrogation function and the data refresh request).
  • inquiry of the query if it has already been executed.

Prerequisite

SEEREFERTTO Refer to documentation Implementation

Screen management

Header

Presentation

The header provides information to identify the query and some setups of a general nature.

Close

 

Fields

The following fields are present on this tab :

Block number 1

This code is used to identify a request.

  • Description (field INTIT)

[object Object]

  • Short description (field INTITSHO)

This title provides a description of the record.
It is used in some screens or reports when there is not enough space to visualize the long title.

  • Active (field ENAFLG)

Select this check box to activate the current record.

Disabled records keep their content and setup but cannot be used (by recalling their code) on other records (documents, settings ...), or for mass processes.

The authorizations to a given function can prohibit the creation of an active record. In this case, the check box is disabled by default. It can only be modified by an authorized user or through a signature Workflow.

Characteristics

  • Query type (field ALLUSR)

Used to manage the display of a query in inquiry mode, with the following behaviors:

  • Normal query: the result of the query is displayed if the query has already been viewed by the user. In effect, if the box is not checked, each user launching the query creates a set of data that belongs to them and which cannot be viewed by anyone else.
  • Shared query: the result of the execution of this query by a user can be viewed by other users. Shared queries are useful in that when a large query is launched at a given moment by a single user, a group of users can then access the common information. It is recommended, for this type of query, that only one user can run the query, the others having inquiry access. In addition, it is preferable to run this type of query in batch mode if it is particularly large; the corresponding batch task code is called CALALH.
  • Recalculated query: the result of the query is never displayed automatically. It is necessary to press on the button to refresh or enter the criteria. This type of query is interesting in that it makes it possible to avoid reloading data if they are known to become rapidly obsolete.
  • Representation (field REPGRA)

This indicator defines the fashion in which the representation of the data will be made in the screen. The possibilities offered are as follows :

  • Character :  the data is uniquely represented un the form of a grid.
  • Char. or Graph. : the data are presented in the form of one or to modes. The default mode is determined by the field Default display defined in the graphical parameters of the record.
  • Char. and Graph. : the data is presented in the both modes simultaneously. The graphical position  with respect to the grid is determined by the field Position for the Graph tab.
  • Character :  the data is uniquely presented in the form of a graph.
  • field OPTGRA

Used to organize the relationship between the character and the graphic, when the presentation mode for the data allows both. According to the case :

  • if the representation is Char or Graph, the default value is chosen for the representation.
  • If the representation is Char and Graph, the position of the graph is given with respect to the data grid.

Close

 

Tab Setups

Presentation

The first tab is used to enter the query and additional general parameters.

In the table called Columns, information to obtain a more precise presentation will be provided. Upon execution, the query returns a list of values which are loaded in the grid. When there is no further information:

  • the grid columns do not have a title.
  • they have the type alphanumeric, numeric, they are dates without much details, depending of the data types returned.

Moreover a fix SQL query does not have much interest. It is necessary to integrate the parameters which are to be entered at the moment of the launch. This is enabled by the grid entitled Parameters.

Close

 

Fields

The following fields are present on this tab :

Block number 1

It defines the code of a report that will be associated with the File / List function from the query inquiry. If this is not entered, the report ALISTE is used, which will submit a default page format. It is possible to duplicate this generic report (in principle it will then only be necessary to modify the page format) to create reports perfectly defined for the query thus defined.

The report code entered here can be associated with a set of print codes via the dedicated function.

Used to link the authorizations to access the query with those authorizations granted on the function.

The principle is as follows: upon entering the query, it is checked that the linked fucntion is authorized to the user (for at least one site, if the authorization on said function is granted by site). This is checked only in the case when this query is not shared.

In effect, if the query is shared, it is admitted that the authorizations of the person that run the query are applied and shared with all those that have the right to view it. It is therefore necessary to be very careful when defining the authorizations of the shared queries if they concern sensitive data. This is done using the access code located in this tab.

This access code makes it possible to prohibit access to the current record for some users.

As a matter of fact, if the field is completed, only the users having this access code with read rights (respectively write rights) can view (respectively modify) the concerned record.

The execution right controls who can execute the query in question (by refreshing the query or by modifying the parameters and then re-running it).

  • Number of lines (field NBRLIG)

Used to define a logical number of lines by page in the inquiry screen generated by the query designer. If this number of lines exceeds the number of physical lines that can be displayed, a scrolling bar appears on the righthand side of the grid. Buttons located in the upper part of the screen will enable navigation between logical pages (view next, previous, last, first page).

  • Maximum lines (field MAXLIG)

The maximum number of lines corresponds to a query parameter (maxrows) that stops the search once the number of lines meets the conditions that have been found in the database (these lines will then be sorted, but the database does not guarantee that the N lines found are the first N in the sort order). This represents an optimization used to limit the database load.

  • Group (field GRP)

Used to make a classification criterion available for requests.

  • No. fixed columns (field NBRCOL)

Makes it possible to fix the first x columns of a grid in the case of horizontal paging.

  • Maximum times (field MAXTIM)

Allows the stopping of the search after this period of time. (expressed in seconds) This makes it possible to avoid waiting too long a time, namely in the case where a new query is being set up.

Note: Contrary to the maximum number of lines, this information is not transmitted to the data base. The maximum time can be exceeded if the duration of the inquiry is too long.

SQL query

  • field TEXTE

The request itself is then entered in the classic SQL form comprehensible by the database.

Several notes on the subject of this request :

  • Any Select request including complex ones can be written here, provided it return a field number less than the maximum admissible.
  • it should be remembered that the NOMCHAMP(index) field, managed in the NOMTABLE table, is defined in the database like the NOMCHAMP_indice field in the NOMTABLE tables, index value 0, 1, 2... N-1, N being the dimension of the field.

For example, it is possible to write :

Select LOGIN_0, CHEF_2 From AUTILIS
Where USR_0 like %1%
Order by CREDAT_0

  • In a request of this type, it is possible to define the parameters using the syntax %N%, which refers to parameter number N defines in the parameters grid (%1% in the example above). These parameters will be entered by means of thebutton during the execution of the request.

Grid Columns

  • Description (field COLTIT)

This data type is used to specify how the data will be presented.. In the case of a local menu, specify the number of the local menu used. If the data type used is linked to an object, it will be possible to use a tunnel to the object management during the enquiry.

  • Menu (field COLNUM)

Used to define a local menu number to be used to present the numerical value of the corresponding column sent by the request.

  • Graph type (field GRA)

This field can only be entered if the representation mode selected in the header is not Character. It is used to specify the fashion in which the graphical representation will be used.

It can take the following values:

  • None or Label if the line field is of the type alphanumeric. The field using the value Labelwill be used as the graph title. Warning, only a line in the grid can take this value ; if it is already present on a line, it will be necessary to first modify the value of the line carrying the value Labelin order to return the value None before being able to assign this value to another line in the grid.
  • None, Valueor Defaultif the field is of the type numeric. The rule is as follows :
    • None signifies that the field will never be presented in the graph.
    • If the graph defined in the last tab is used to make several series appear, all the series corresponding to the fields marked Defaultwill be displayed (provided they haven't already).
    • if the graph in the last tab is not used to make a series appear, the column corresponding to the first field marked Defaultwill be displayed (this will be the first if none has been declared before).
  • Representation (field REP)

This field can only be entered :

  • if the representation method chosen in the header is not Character.
  • on the numeric fields where a value will be displayed.

It is used to manage the graph combinations if the graphic type defined in the graphical parameters is used to make several series appear, independently of different types (it is ignored in other cases). In practice, the usable combinations are as follows :

  • Type = Multi graph, Default graph=Lines, Representation=Multi
  • Type = Multi graph, Default graph=Bars, Representation=Multi

The rule is as follows :

  • Defaultsignifies that the graphical presentation of the series corresponds to the default graph of the last tab (Bars, or Linesin this case).
  • Bar or Line is used to force the corresponding presentation method in question.

Grid Parameters

  • Description (field PARTIT)

If this field is entered, a parameter where the title corresponds to this field can be entered before the execution of the request (using the button).

This parameter can be used in the body of the request by means of the syntax %N%, where N is the corresponding line number in the parameters grid.

This data type is used to facilitate the entry of the corresponding parameter. In fact, if a type is defined :

  • the format controls are carried out.
  • If the data type used is linked to an object, it is possible to use the corresponding selection window.
  • Menu (field PARNUM)

Used to define a local menu number to be used to enter the parameter value.

  • Default value (field VALDEB)

 

Close

 

Tab Graphic

Presentation

This tab can only be entered if a graphical representation is available for the query. The way the data are displayed on the graphic is then defined.

Close

 

Fields

The following fields are present on this tab :

Graph

  • Type (field TYPGRA)

This field is used once there is more than one numeric value in the grid that is likely to be presented in a graphical form. It can take one of two values :

  • Single graph : in this case, only one column of values is displayed at a time (a selector is used to make to choice)/
  • Multi-graph : in this case, all the columns are displayed, combined according to the parameter defined by the parameter Representation.
  • Representation (field FSHGRA)

When several series are presented in the graph (provided that the presentation of all the series is identical and is not by sector type), it is possible to specify how the series values are combined in the display, by entering the following value :

  • Multiis used to present the values of each series side by side (one color by series)
  • Cumulative is used to present the values in a vertical total.
  • Comparative is used to present them in a relative comparison (the height of the graph is constant).
  • Default graph (field DEFGRA)

Defines the graphical representation used for the data to be presented (from the choices Bars, Lines, Area, Sectors). An image is displayed as a function of the choice made illustrating the type of presentation obtained.

If only one series of values is available, the graphical representation is by default fixed by this parameter.

If several series of values are presented, it is possible to mix the presentation modes (one series in the form of bars, another in the form of lines for example). In this case, each series of values is represented as a function of the field Representation located in the grid of fields :

  • if it is Baror Line, this representation mode is used for the series of values concerned if it is compatible with the default graphical representation (it is not possible to mix sectors with bars or lines).
  • if it is Default, the default graphical representation for the series is used.

When used, if the representation of the series is homogenous (that is there is only one series in the graph), there is a graph type selector for the user to select a different mode of presentation.

Block number 3

  • field IMAG

Image explaining the information previously entered.

Block number 2

Block number 4

Close

 

Important note

It should be noted that no filter linked to authorizations is carried out (irrespective of whether they are authorizes by role, by site or by access codes) with the SQL query tool. It is therefore advisable to protect the queries of this type with an access code to limit the display rights and even more the execution of these queries. Similarly, the access to this function must normally be limited to a restricted list of users.

Specific Buttons

generates the screen associated with the inquiry and verifies the query by submitting it to the database for the verification of the syntax and the semantics.

Is used to execute the current query. The execution is launched by updating a temporary table passes to the function to view queries, which makes it possible to view the result of the query. 

The following fields are included on the window opened through this button :

Block number 1

  • field OBJET

 

  • field CLES

 

Block number 2

  • From folder (field DOSORG)

Indicate the folder from which the record is going be copied. The possible syntaxes are described in the dedicated appendix.

  • All folders (field TOUDOS)

This option is used to copy the record to all the folders defined in the dictionary (ADOSSIER table from the current solution).

  • To folder (field DOSDES)

Indicate the folder in which the record is going be copied. The possible syntaxes are described in the dedicated appendix.

Close

This button is used to copy the record definition from or to another folder.

Error messages

In addition to the generic error messages, the following messages can appear during the entry :

query incorrect

[error description returned by the database]

From the point of view of the database the query is incorrect. Either it is not correct from the point of view of the syntax or the element does not exist. The description provided gives the title of the error returned by the database.

Not possible to access this record

An attempt has been made to access a query created with the classic query tool using the SQL query tool (the codes in a query belonging to the SQL query tool cannot be used to name a classic query and vice versa).

Too many fields

The query has returned too many columns. It should be noted that the number of columns that can be read by the SQL query tool is limited to 120.

Tables used

SEEREFERTTO Refer to documentation Implementation