How to resolve the error "Unable to assign a NULL value to column "cachekey" since the column is not nullable." in TIBCO Data Virtualization?

How to resolve the error "Unable to assign a NULL value to column "cachekey" since the column is not nullable." in TIBCO Data Virtualization?

book

Article ID: KB0072284

calendar_today

Updated On:

Products Versions
TIBCO Data Virtualization All supported versions

Description

When a user configures Incremental caching in TIBCO Data Virtualization, they may encounter the below error message while executing the "Initial Snapshot" (A script used to create the cache table):
-----------------------
A system exception has occurred.  
  at AnonymousProcedure (line 16)
  caused by: Unable to assign a NULL value to column "cachekey" since the column is not nullable.  [data-2911084]  [script-1900011]
Unable to assign a NULL value to column "cachekey" since the column is not nullable.

-----------------------

A typical Initial Script uses the GetEnvironment call in the procedure to fetch the cacheKey. This error points out that the procedure is not passing the cacheKey during the process.

-----------------------
CALL /lib/util/GetEnvironment('System.CACHED_RESOURCE_CACHE_KEY', cacheKey);
-----------------------

- A sample procedure can be created to test if the GetEnvironment is not fetching the cacheKey at all and is forwarding it as Null.
-----------------------
PROCEDURE GetCacheKey()
BEGIN
    DECLARE cacheKey BIGINT;
    CALL /lib/util/GetEnvironment('System.CACHED_RESOURCE_CACHE_KEY', cacheKey);
    CALL /lib/debug/Log('CHECKPOINT # 1: cachedResourceCacheKey = ' || cacheKey);
END
-----------------------
- When the procedure GetCacheKey() is executed, it may not return any value and this is the reason that NULL is being inserted into the cacheKey column which is marked as Not Null.
 

Environment

All supported environment

Resolution

The cache key is generated every time a cache is refreshed, i.e when the Refresh Cache is hit. This could be because the table is not cached and therefore the refresh was never done and hence NULL was being passed for the cache key.

Make sure that the table is cached, if the table is cached then refresh the cache table to generate the cachekey. 

Issue/Introduction

This article explains the error message and also points out possible solutions to get rid of the error message.