Previous Topic: Virtual Fields and Access Paths

Next Topic: Virtualizing Virtual Fields

Example of Using Virtual Fields

Because the Order detail file Refers to the Product file, you can specify any Product detail, such as Product name or Pack size, as a virtual field on the Order detail file. For example:

FIL

FIL

FIL

Product

Product

Product

REF

REF

REF

Known by

Has

Has

FLD

FLD

FLD

Product code

Product name

Pack size

CDE

TXT

QTY

Any file that has a Refers to relationship with a relation that refers to Product can include any non-key field of Product as a virtual field. For example, an order detail line can include Product name and Pack size as virtuals:

FIL

 

Order detail

CPT

Refers to

FIL

VRT

VRT

Product

Product name

Pack size

REF

TXT

QTY

By indicating a field on the Product file (referenced file) as a virtual field, you allow the system to make the data contained in this particular field of the Product file available for functions that operate on the Order Detail file (referencing file).

In this case, the Order Detail file may include any of the non-key fields of the Product file as virtual fields.

When you specify virtual fields for a relation, CA 2E generates the necessary source to join the files that actually contain the virtual field to the related file. For DDS, this process is usually implemented through the use of an i OS join logical file. For SQL, a view over multiple tables is used. Because of i OS limitations, CA 2E generates special logic to support virtual fields in SPN access paths.

You can only add virtual fields to relations that connect a pair of files through the relation types Owned by, Refers to, and Extended by.

When you specify virtual fields for a file that references itself, sequence the Refers to as the last relation.