When ObjectLand should display records of EDB query built by constructive method, it automatically forms SQL statement SELECT which takes into account all properties of the query – conditions of searching and sorting records, joining tables, set of displayed field, etc. When it is a question of displaying records linked with particular selected feature, the clauses which check coincidence of values of fields of direct or indirect link with required values are automatically included into the text of SELECT statement.
If the query is built by specifying SQL statement SELECT by the user directly, ObjectLand does not have a possibility to automatically determine the place in this statement in which it is possible to build in the fragment which could take into account the value of the field of direct link or values of fields of indirect link. The reason for this is the arbitrary complexity of structure of the specified statement SELECT. The consequence is impossibility to get query records linked with the feature. To solve this problem ObjectLand provides a mechanism of control sequence of link. This sequence is a string of characters of a special format which the user inserts in the specified statement SELECT. Control sequence denotes a place of insertion of the condition of getting record linked with the feature.
When sending a request to view all query records, ObjectLand removes the control sequence of link from SQL statement SELECT. When getting records linked with the feature, ObjectLand finds the control sequence of link in the statement SELECT and replaces it by the fragment which takes into account the value of field of direct link or values of fields of indirect link.
Absence of control sequence of link does not permit the user to get query records linked with the feature. Getting features linked with the records is provided even when the control sequence is absent.
Description of control sequence of link below is intended for users who have knowledge about syntax and semantic of SQL language and of statement SELECT in particular.
Syntax of control sequence of link is shown below:
{link <logical operator> < link fields >}
Here <logical operator> is one of the words WHERE or AND. If the parameter <logical operator> is absent, it is supposed that the logical operator AND is used.
<link fields> is either a name of field of direct link in a query or a sequence of names of fields of indirect link separated by commas. The order of names of fields should correspond to the order of names of fields of indirect link specified when the link between EDB query and feature type was set.
Names of fields in control sequence of link should coincide with names used in the list of obtained fields of SQL statement (including used qualifiers of field names and/or aliases of field names.
Names of fields in control sequence of link can be absent, in this case names of corresponding query fields are used. A list of field names in the control sequence of link can be incomplete; in this case missing field names will be taken from query field names. Absence of field names or partial specifying of field names in control sequence of link is possible, if field names in the list of obtained fields of SQL statement SELECT do not contain qualifiers and when there are no aliases of field names, otherwise it is possible that a syntax error appears in SQL statement SELECT.
It is necessary to place the control sequence of link in the body of SQL statement SELECT correctly.
If the SQL statement does not contain the clause WHERE, control sequence of link should be placed into position admissible for the clause WHERE. The logical operator in control sequence of link should take the value WHERE.
If SQL statement SELECT contains the clause WHERE, control sequence of link should be placed into position which provides the possibility to combine the search condition specified by the clause WHERE with condition of link by which control sequence of link will be replaced, when records linked with the feature are retrieved, using the conjunction operation. The logical operator in control sequence of link should take the value AND (or be absent).
Below you will find three examples which illustrate the rules of specifying control sequence of link.
SELECT FIELD1, FIELD2
FROM TABLE1 {link WHERE}
In this example <logical operator> in control sequence of link takes the value WHERE, since there is no clause WHERE in SQL statement SELECT. Names of fields in control sequence of link are absent, because names of fields are specified without qualifiers and aliases in the list of obtained fields of SQL statement SELECT.
SELECT FIELD1 AS F1, FIELD2 AS F2
FROM TABLE1 {link WHERE F1, F2}
In this example <logical operator> in control sequence of link takes the value WHERE, since there is no clause WHERE in SQL statement SELECT. Names of fields in control sequence of link are present, because aliases of field names are specified in the list of obtained fields of SQL statement SELECT.
SELECT FIELD1,FIELD2
FROM TABLE1
WHERE FIELD1='SMITH' {link}
In this example <logical operator> in control sequence of link is absent (default logical operator AND is used), since there is the clause WHERE present in SQL statement SELECT. Names of fields in control sequence of link are absent, because names of fields are specified without qualifiers and aliases in the list of obtained fields of SQL statement SELECT.