Adhere to the following guidelines for functions in computed column libraries:
Computed columns may be accessed by SQL, reports, screens, and PSL code. Therefore, label all functions with computed column libraries as Public functions.
Functions cannot throw errors or return error flags. Code all functions to complete under all circumstances, including errors. The functions should return either a null value or default value (as documented) if they process an unrecoverable error condition. The functions can log error conditions as appropriate.
Functions should not use Cache objects, with the exception of CUVAR.
Computed libraries should only contain functions that relate to the associated tables that are joined to it. If a table does not have a computed library procedure, create one.
Functions cannot make durable or externally visible changes to the database state. A function is provided to report the results of a view of data that cannot be provided by static columns.
Functions must represent the current process state of PSL objects on the associated table. Joined tables will contain the current database state relative to the process scope (i.e., uncommitted database transactions will be visible).
If a function must instantiate the object that the function refers to, use the classNew parameter in the Db.getRecord method.
A computed function must be independent of any variable in the run-time environment, other than system variables. All variables used by the computed column, other than system variables, must be typed within the function.
Computed library routines should be compiled with the #OPTIMIZE and #WARN switches on.
Computed library routines should correlate to DATA-QWIK tables on a one-to-one basis (e.g., the DEPCDI library routine contains computed columns for DEP only). The library routines should only contain line tags that have a computed column in the dictionary, or are used as a common subroutine by computed functions within the routine.
Tests for correctness of how a computed function is written include:
If a computed function is executed with an empty symbol table as a starting point, the symbol table is still empty after the function execution.
No Public scope declarations are made within the function.
No scope warnings occur at compile time.
When Standard is Enforced: Profile v7.0