Local fields and QAB standard variables are referenced using the full field name.
The full form for referencing a database fields is as follows:
tablename.identifying role.fieldname.fieldrole
Blank identifying roles and field roles are denoted by _. When compiling QAB programs the compiler will accept non ambiguous abbreviated field names in the following formats:
fieldname
fieldname.fieldrole
tablename.fieldname
tablename.fieldname.fieldrole
tablename.identifying role.fieldname
If an abbreviated definition could refer to more than one field, a compiler error will be generated. Because modification to a program or a database could render a formerly unambiguous reference ambiguous, or a reference could be ambiguous when a procedure is used in one program but not another, it is a good idea always to specify field names in full. Using abbreviated names should be confined to small, or programs you are prototyping. They should not be used in programs that are part of a complex system.
Consider the following table:
EMPLOYEE
1 STAFF_NR N3
* SHORT_NAME U10
NAME C25
ADDRESS C25x4
* STAFF_NR N3
(MANAGER)
|
An order entry program would probably only refer to one copy of the employee table, so the following would be an acceptable reference to the employee name:
employee.name
In a program that maintained the employee table you would need two copies of the employee table : employee.main and employee.manager, so that the staff_nr(manager) field could be validated. Therefore the program would have to specify the employee name fields as follows:
employee.main.name {employee name}employee.manager.name {manager name}
Because the staff_nr field occurs in the table twice, the field role must always be specified. In the order entry program you could use:
employee.staff_nr._
In the employee maintenance program you could refer to the following four instances of the staff_nr field:
employee.main.staff_nr._ {employee number}employee.main.staff_nr.manager {manager number}
employee.manager.staff_nr._ {manager number}employee.manager.staff_nr.manager {manager's manager number}
The only way to avoid ambiguity is to use the full form of the field specification. Note that the database logic will ensure that the second and third instances of the staff_nr field will be the same. However the formula compiler does not take this into account.
$ may be used to refer to the current field in the following three places:
The $ equates to the complete field. For example if you have an item of field processing for and address field that specifies a low and high occurs of 2 to refer to the second line of the address. $ still refers to the whole address field. You must use $[2] to refer to the second line of the address.