Virtual Column Concepts

A virtual column is a special feature provided as part of the LANSA Repository.  Used properly, virtual columns can be very helpful in simplifying the processing of logic within applications and in improving the user interface of your applications.

A virtual column is a column which appears as part of a table but does not actually exist in the physical database table. Its value is dynamically derived based on the columns in the table.  (Virtual columns can also be derived from other virtual columns.) Virtual columns provide flexibility, since you can combine or extract data from columns in a table and extend the information already contained in the table.

You may use virtual columns for implementing "conceptual structures" within the database.  For example, you can take the columns CENTURY, YEAR, MONTH, DAY to create a single column called date.  You could also store a date in YYMMDD format but retrieve and display it as MMDDYY or DDMMYY.

To a program, the column appears to exist as part of the table; however, the value is not actually stored but derived by the I/O Module when the record is input or output from the table.  If you were to display the contents of the table, you would not see the virtual columns. Hence, virtual columns cannot be used as keys in a table. Some examples of using virtual columns:

You can use virtual columns to simplify, standardize and centralize column related string handling, conversions and calculations.

A virtual column must be defined in the Repository and may have column and table level validations associated with it.  Also, validation rules for the columns used in defining the virtual column are still enforced.  A virtual column can be used like any other column in the Repository.

Virtual columns are not part of the real table and cannot be directly used outside of LANSA.  Virtual columns are made possible using LANSA's Object Access Module. Client applications using LANSA Open and any applications which use the LANSA Object Access Module can access the LANSA virtual columns.

Virtual columns are derived and are not real columns in the table. Virtual columns cannot be used as a key column for a physical table or an index. If you require columns for these purposes, you will need to make them into real columns as opposed to virtual columns.

LANSA provides several methods of defining virtual columns:

RPG or C coded definitions may be necessary for complex actions such as type and length conversions, date to age conversions, or dynamic data conversion.

Also, review the Predetermined Join Column Concepts for details about another form of virtual column that may use column values from other tables.

Also See

Distinction between real and virtual columns

Examples of Virtual Column Applications