Developer Documentation Library > Data Model > Accessing the UNICOM Intelligence Data Model > Working with the Metadata Model > Derived variables > Persisted derived variables
 
Persisted derived variables
A persisted derived variable is simply a dynamically derived variable whose results have been permanently written into the case data.
This topic shows you how to create a persisted derived variable. The example uses the TotalInGroup dynamically derived numeric variable that we created in Dynamically derived variables.
The process of converting a dynamically derived variable into a persisted derived variable is quite simple. In DM Query, open the museum_dd_expression.mdd and museum_dd_expression.ddf files that we created in the previous topic. For step-by-step instructions, see How to run the example queries in DM Query using the museum sample, but make sure that you select museum_dd_expression.mdd and museum_dd_expression.ddf instead of museum.mdd and museum.ddf, and this time select Open Metadata Read/Write.
Type this statement in the SQL box:
ALTER TABLE vdata ADD COLUMN PersistedTotalInGroup LONG
This statement created a new variable in the case data called PersistedTotalInGroup. Now we need to write the results of our dynamically derived variable TotalInGroup to this new case data variable. You do that with the following statement:
UPDATE vdata SET PersistedTotalInGroup = TotalInGroup
We have now written the results of the dynamically derived numeric variable TotalInGroup permanently into the case data as a new persisted derived numeric variable called PersistedTotalInGroup.
Provided you selected the option to open the museum_dd_expression.mdd file in read/write mode, the UNICOM Intelligence OLE DB Provider will have created a variable called PersistedTotalInGroup in the metadata. To tidy things up you should now go back into the metadata and add a label for the variable.
Notes
To be able to create a new variable in the case data in this way requires that the CDSC is write-enabled and that it supports DDL Column and UPDATE. For details of the supported features of the CDSCs that come with the UNICOM Intelligence Data Model, see Supported features of the CDSCs.
When you use the xp_syncdb extended stored procedure to synchronize the case data with the MDM document, xp_syncdb does not create a variable in the case data for a derived variable.
See also
Derived variables
Dynamically derived variables