This method of building EDB query differs from the previous one considerably. To create a query the user should perform the command Edit+Add of the navigation window (provided the component “Queries” of one of the opened EDBs is selected in the pane of components). It is required to enter a name of the query being created in the dialog box “Adding query” and check the radio button SQL statement SELECT. The view of the dialog box for this case is shown at figure 41-2.
Figure 41-2. Dialog box “Adding query”, direct specifying of statement SELECT
The big pane in the lower part of the dialog box is intended for entering text specifying SELECT statement. Originally, the dialog box displays the standard phrase “Select * from ”. The simplest correct variant to specify the statement SELECT will be obtained if one adds a name of some EDB table at the end of this phrase, for example: “Select * from `Building certificates`”. Inverse apostrophes are necessary according to grammatical rules of SQL language if the name of the table contains spaces. This example of SELECT statement denotes selection of all records from the specified table.
The user who knows SQL language well can specify SELECT statement of any complexity. It is also possible specify conditions of sorting and searching records in this statement, join EDB tables in different ways and so on.
To be able to compose a text of SELECT statement easier there are three drop-down lists above the input pane: Owner, Table and Field. They serve for substitution of names of corresponding entities from EDB into the statement text. The list Owner is accessible only if the data sources support the notion of data owner. The list Table contains names of all tables of the present EDB. If the owner's name is specified, only tables based on components of data belonging to this owner are displayed. The list Field contains names of all fields of selected table.
To use names from lists in the text of SELECT statement it is necessary to place the input caret to the required place of the text being entered, select the necessary name in the list of owners, tables or fields and then push the button
or
.
When pushing the button
, the name from the corresponding list, for example, field name `Inventory number` will be inserted into the position of input caret.
When pushing the button
, a qualified name will be inserted into the position of input caret. For a table it will be <owner's name>.<table name>, for a field – <owner's name>.<table name>.<field name>, for example, Administrator.`Building certificates`.`Inventory number`. Owner's name is available only for those data sources which support this notion.
It is preferable to use the buttons
or
than entering the corresponding names from the keyboard. For example, a concrete data source could require a different name delimiter than inverse apostrophes. When using the buttons it is guaranteed that the format of recording names will satisfy requirements of the source.
If SELECT statement is written correctly and the name of the query is specified, after pushing the button OK a cataloged query on the basis of specified SQL statement SELECT will be created.
When browsing such a query, user's possibilities to change query properties are limited. The user can hide and display record fields, change their width and displayed names, set and reset reference fields. At the same time commands Fields+Calculations, Fields+Join and Tools+Search are disabled. It is explained by the fact that in this case calculations, joining, searching and some other operations should be specified by modifying the statement SELECT on the basis of which the query is built.
Just like for queries of other types there is a possibility to duplicate the query on the basis of the statement SELECT using the menu command Edit+Duplicate.
Another method of building a query on the basis of SQL statement SELECT is connected with using of the menu command Tools+Search which is enabled if opened EDB is selected in the pane of the navigation window. After executing this command the dialog box “Search” shown at figure 41-3 will be opened.
Figure 41-3. Dialog box “Search”
The figure shows that the contents of this dialog box fully coincide with the lower part of the dialog box “Adding query” for the query on the basis of SQL statement SELECT (see figure 41-2). The field of query name is absent. Building of the statement SELECT is performed exactly in the same way as it was described above. After pushing the button OK the system sends a request to an external data source and opens a browser window for received non-cataloged query. When necessary the user can catalog the query by performing the command Query+Save from the menu of the browser window.