Try OpenEdge Now
skip to main content
Programming Interfaces
Data Management : Database Access : Multi-database programming techniques : Referencing tables and fields
 
Referencing tables and fields
Unique table and field names do not require fully qualified references within application procedures. In a single database OpenEdge application, references to non-unique field names require a table prefix to avoid ambiguous field references. Use the following syntax to reference a non-unique field in a procedure:

Syntax

table-name.field-name
The tablename is the name of the database table that contains the field fieldname.
The ability to connect to several databases from a single OpenEdge session introduces the possibility of non-unique table names and increases the possibility of non-unique field names. References to non-unique table names within multi-database OpenEdge applications require database prefixes to avoid ambiguous table references. Ambiguous table and field references cause compilation failures.
Use the following syntax to include a database prefix in a table or field reference:

Syntax

database-name.table-name
database-name.table-name.field-name
The databasename is the logical name (or an alias for a logical name) that represents the database that contains the table tablename.
For example, suppose you are connected to two databases db1 and db2, both of which contain a table called Customer. The following procedure will not compile due to an ambiguous table reference:
FOR EACH Customer: /* In db1 or db2 ? */
  DISPLAY Customer.Name.
END.
The procedure below uses fully qualified table references to display Customer names from both connected databases (db1 and db2):
FOR EACH db1.Customer:
  DISPLAY Customer.Name.
END.
FOR EACH db2.Customer:
  DISPLAY Customer.Name.
END.
Notice that the two references to the name field do not need to be qualified because they appear within a FOR EACH block that already contain fully qualified table references.
Note: When the AVM encounters a statement such as DISPLAY X.Y, it first attempts to process X.Y as a databasename.tablename. If that fails, the AVM then attempts to process X.Y as tablename.fieldname.