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
Refer to documentation Implementation
Screen management
Header
The header provides information to identify the query and some setups of a general nature.
Block number 1
Query (field COD) |
This code is used to identify a request. |
Description (field INTIT) |
Use this field to assign a description to each record. |
Short description (field INTITSHO) |
This title, which describes the record, is used in some screens or records when there is not enough space to display 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:
The authorizations for 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:
|
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 :
|
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 :
|
Tab Setups
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.
Block number 1
Report (field RPT) |
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. |
Function (field FCTLNK) |
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. |
Access code (field ACS) |
This access code makes it possible to prohibit access to the current record for some users. If the field is populated, only users that have this access code with read access rights (and write access rights respectively) can view (or with write access rights, modify) the 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. of 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 :
|
Grid Columns
Description (field COLTIT) |
Type (field COLTYP) |
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:
|
Representation (field REP) |
This field can only be entered :
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 :
The rule is as follows :
|
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. |
Type (field PARTYP) |
This data type is used to facilitate the entry of the corresponding parameter. In fact, if a type is defined :
|
Menu (field PARNUM) |
Used to define a local menu number to be used to enter the parameter value. |
Default value (field VALDEB) |
Tab Graphic
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.
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 :
|
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 :
|
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 :
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
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
Validate |
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. |
Execute |
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. |
Copy
This button is used to copy the record definition from or to another folder. Block number 1
Block number 2
|