Considerations regarding inserting into, and updating, computed columns include the following:
Direct inserts and updates You should not use INSERT or UPDATE statements to put values into computed columns since the values may not reflect the intended computation. Also, manually inserted or updated data in computed columns may be changed later when the column is recomputed.
Column dependencies It is strongly recommended that you not use triggers to set the value of a column referenced in the definition of a computed column (for example, to change a NULL value to a not-NULL value), as this can result in the value of the computed column not reflecting its intended computation.
Listing column names You must always explicitly specify column names in INSERT statements on tables with computed columns.
Triggers If you define triggers on a computed column, any INSERT or UPDATE statement that affects the column fires the triggers.
Although you can use INSERT, UPDATE, or LOAD TABLE statements to insert values in computed columns, this is neither the recommended nor intended application of this feature.
The LOAD TABLE statement permits the optional computation of computed columns. Suppressing computation during a load operation may make performing complex unload/reload sequences faster. It can also be useful when the value of a computed column must stay constant, even though the COMPUTE expression refers a non-deterministic value, such as CURRENT TIMESTAMP.
Avoid changing the values of dependent columns in triggers as it may cause the value of the computed column to be inconsistent with the column definition.
If a computed column x depends on a column y that is declared not-NULL, then an attempt to set y to NULL will be rejected with an error before triggers fire.
|Envoyer votre avis sur cette page par email.||Copyright © 2009, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.1|