Configure expression-based retention when you want to base the retention period for records in an entity on an expression date. The expiration date for each record in the entity equals the retention period plus the date that the expression returns.
The expression must include statements that evaluate to a column date or to a single date value in DATE datatype. It can include all SQL statements that the Data Vault Service supports. The expression can include up to 4000 characters. If the expression does not return a date or if the expression syntax is not valid, the Update Retention Policy job fails. To prevent the Update Retention Policy job from failing, provide null-handling functions such as IFNULL or COALESCE in your expressions. This ensures that a suitable default value will be applied to records when the expression evaluates to a null or empty value.
The Update Retention Policy job includes the expression in the select statement that the job generates. The job selects the records from the Data Vault. It uses the date that the expression returns to update the retention expiration date for the selected records. When you monitor the Update Retention Policy job status, you can view the expression in the job parameters and in the job log. The job parameter displays up to 250 characters of the expression. The job log displays the full expression.
Use expressions to evaluate any of the following types of table data:
Dates in integer format
Use the TO_DATE function to evaluate columns that store dates as integers. The function converts the integer datatype format to the date datatype format so that the Update Retention Policy job can calculate the retention period based on the converted date. The TO_DATE function selects from the entity driving table.
To select a column from another table in the entity, use the full SQL select statement. For example, you want to set the retention policy to expire records 10 years after the employee termination date. The entity driving table, EMPLOYEE, includes the TERM_DATE column which stores the termination date as an integer, for example, 13052006. Create a retention policy, and set the retention period to 10 years. Add the following expression to the retention policy:
TO_DATE(TERM_DATE,'ddmmyyyy')
When the Update Retention Policy job runs, the job converts 13052006 to 05-13-2006 and sets the expiration date to 05-13-2016.
Dates or other values in tags
Add tags to archived records to capture dates or other values that might not be stored or available in the Data Vault. Use an expression to evaluate the tag and set the retention period based on the tag value.
For example, you retired a source application that contained products and manufacturing dates. You want to set the expiration date for product records to 10 years after the last manufacturing date. When you retired the application, some products were still in production and did not have a last manufactured date. To add a date to records that were archived without a last manufacturing date, you can add a tag column with dates. Then, define a retention policy and use an expression to evaluate the date tag.
Data from all tables in the Data Vault archive folder
Use an expression to evaluate table columns across all entities in the Data Vault archive folder. You can use a simple SQL statement to evaluate data from one column, or you can use complex SQL statements to evaluate data from multiple columns.
For example, you retired an application that contained car insurance policies. An insurance policy might have related messages and claims. You want to set the expiration date for insurance policy records to five years after the latest transaction date from the POLICY, MESSAGES, or CLAIMS tables. If the insurance policy has a medical or property damage claim over $100,000, you want to set the expiration date to 10 years.
If you enter a complex SQL statement that evaluates column dates across high-volume tables, you might be able to increase query performance by changing the retention policy for specific records. Change the retention policy for records and then run the Update Retention Policy job instead of entering an expression to evaluate date columns across tables. Data Archive can generate SQL queries which run more quickly than user-entered queries that perform unions of large tables and contain complex grouping.
You can configure expression-based retention in the workbench when you manage retention policies or when you change retention policies for archived records in Data Discovery. The retention policy list in Data Discovery appends "(Expression)" to the names of retention policies with expression-based associations. You cannot configure expression-based retention for retention policies with indefinite retention periods.