LINK |
Link is used to define a set of links between various tables, as well as single abbreviation to access these tables with one instruction. (example: Read).
Link class_p With list_links As class_l [ where_cl ] [ order_by_cl ]
|
Element |
Description |
Restrictions |
|
class_p |
class indicating the abbreviation for the main file. |
The file must be open. |
|
list_links |
List of links separated by the character ','. |
Number of links<50 |
|
link |
Definition of a link in the form key '=' list_expr_key |
None. |
|
key |
Indication of the key for a
linked file in one of the forms: |
The linked file must be open. |
|
id_key |
nom_de_variable indicating a key |
None. |
|
exp_ind |
Integer expression of the number of parts of the keys used. The whole key is used by default. |
0<=exp_ind<= number of components of the key (8 max). |
|
list_expr_key |
List ofexpr_key separated by the character ';' and matching the values of the sub-keys. |
No more than 8 sub-keys |
|
expr_key |
Any expression for |
Compatible with the sub-key type, according to operator and functions. |
|
operators |
comparison =, <, >,
<=, >=, <> |
None. |
|
functions |
Alphanumeric, numerical, dates |
According to type. |
|
Alphanumeric |
left$, right$, mid$, seg$, len, num$, ctrans, tolower, toupper, val, ascii, chr$, instr, pat, string$, space$, mid$, virebl. |
None. |
|
Numerical |
abs, int, ar2, avg, var, prd. |
None |
|
Date |
No function allowed |
|
|
Multi-type |
find, max, min, sigma, uni. |
Except Date type |
|
class_l |
class indicating an abbreviation for accessing all linked files. |
The abbreviation must |
|
where_cl |
See Where instruction |
None. |
|
order_by_cl |
See Where instruction |
None. |
# Extract from a routine giving the history
of the product by client:
# Opening main and linked files with a
selection criterion on
# the PRODUIT file
File HISTORIQUE [HIS], CLIENT [CLI], PRODUIT [PRO]
& Where [PRO]CLE
>= [M:E]PRPRO & [PRO]CLE <= [M:E]DRPRO
#
# Definition of links between the
HISTORIQUE file and the
# PRODUIT file on the one hand and the
CLIENT file on the other. Definition of
# the link abbreviation [LIEN] and the
pseudo-key KEY1
Link [HIS] With
[PRO]CODPRO = NUMPRO, [CLI]NUMCLI = NUMCLI
& As [LIEN]
& Order By Key KEY1
= [PRO]CLE;[CLI]CLE
#
# Immediate use
For [LIEN]KEY1
PRIHT +=
[HIS]PRIHT*(([HIS]TYPCOM = 1)-([HIS]TYPCOM = 2))
Next
# Declaration of files and definition of a
link with invoices sorted
# by client department.
File FACTURE [FAK], CLIENT [CLI]
Link [FAK] With [CLI]NUMCOD = NUMCOD As [DEP]
& Order By Key
DEPT = [F:FAK]ADFAC(2)
Link is used to define a set of links between a main table and annexed tables, specifying any selection and sort criteria, and to define an abbreviation (that we will call the link abbreviation) to access all these tables with a single Read or For instruction. Main table and linked tables must first have been opened with a File or Local File command.
The main file abbreviation is used to access this file (in read or write mode) using the keys defined in the parameters, unless an Order by clause has redefined a key for this file.
The Order By clause in Link is used to define (or redefine) the main file scanning index when the link abbreviation is used. During a Read (on the main file) with this abbreviation, Adonix tries to read the record for the main file, then a record in each additional file, as a function of what has been given in list_links. If this clause exists, only the index found there may be used for an operation on the file. Refer to the specific documentation for this clause for more details.
The keys that can be used with the link shortcut are:
· the key defined in the Order By clause in Link (if there is one);
· otherwise, the key defined in the Order By clause for the file, for the main file (if there is one) or the last Filter performed on this file;
· otherwise, one of the keys defined in the main file parameters.
The Where clause is used to restrict access to the file records for which the expression given has been verified. It adds an additional restriction to any Where clauses defined on the files to be linked (if necessary). It should be stated that this expression (except when it is a file field) is evaluated when the table is opened (unlike earlier versions). The list of operators and functions that can be used is limited. Refer to the specific documentation for this clause for more details.
The link abbreviation does not give access to the main file in write (by Delete, Write, Rewrite or Update).
There is no class [F] or class [G] associated with the link abbreviation.
The abbreviation must be unique. If a file has already been opened with this shortcut, it is not closed again with Adonix, but an error message is generated. The behaviour of Link is the same as that of a Local File.
Only one link may be defined for each main file. This means that defining a second link for a given file closes the first.
A link may be only be defined on tables located on the same server.
A filter may be defined (with Filter) on a link file.
|
Error |
Description |
|
PAFIC (20) |
- The main file is not open. |
|
ERREOP (28) |
Shortcut (for link) already used. |
|
PACLE (21) |
Non-existent key (linked file). |
|
ERCLAS ( 7) |
Main file or linked file not open. |
READ - FILE - FILTER - ORDER - WHERE - CHOOSE - FOR - TREEBOX
|
|