SETURLKEY - connect_cdc_sqdata - Latest

Connect CDC (SQData) Apply engine

Product type
Software
Portfolio
Integrate
Product family
Connect
Product
Connect > Connect CDC (SQData)
Version
Latest
ft:locale
en-US
Product name
Connect CDC (SQData)
ft:title
Connect CDC (SQData) Apply engine
Copyright
2025
First publish date
2000
ft:lastEdition
2025-03-03
ft:lastPublication
2025-03-03T15:29:41.860000

The SETURLKEY function provides an alternative to the default Topic partitioning options provided by the Kafka DATASTORE url.

Important: The SETURLKEY with correctly provided URL specification is compatible with the KEY IS clause which appears on a DESCRIPTION or target DATASTORE statement. Keys formed by SETURLKEY do not contain embedded or trailing binary zeros (null delimiters). Keys formed solely from the KEY IS clause without the use of SETURLKEY have a binary zero after each concatenated part of the key. If you want to eliminate the embedded/trailing delimiters between parts of a key, you must use SETURLKEY to create the partitioning key.
DATASTORE kafka://.../...[/<partition> |/key |/root_key |/]

Category

Specialized

Syntax
SETURLKEY(<target_datastore>, <concatenated_key>)
Parameter and Description
Parameter Description
<concatenated_key> Any combination of literals, variables, source alias references and source data concatenated to create a partitioning key.

Best Practices

  • In order for partitioning keys to be given to Kafka when writing a message, regardless of the method used to create them, the KEY IS clause must be specified on a DESCRIPTION or target DATASTORE statement. One or more column or field names may be specified, and each must exist in the description.
    Note: A dummy or placeholder name cannot be used.
    The KEY IS clause must be present and valid, even if you intend to override it using SETURLKEY.
  • If you want the key to be formed automatically from the column or field names specified on the KEY IS clause, specify the Kafka URL with /key or /root_key at the end. The key will have a null terminator (Unicode \u0000) at the end of each part of the key.
  • If you want to create the key dynamically using SETURLKEY:
    • specify a non-generic topic name in the URL (i.e., no asterisk)
    • terminate the URL with a slash '/'
    • do not code /key or /root_key in the URL
    The key can be constructed from one or more column or field names and/or variables. The key will not have a null terminator at the end of each part of the key. If you need to specify different topic names, use SETURL.
  • SETURLKEY cannot be used with a generic URL.

Examples

Example 1

Partition Kafka topics using both the both the source data key and the abbreviated State from the source table change data records.
DESCRIPTION DB2SQL ./DB2DDL/EMP.ddl AS EMP;
DESCRIPTION DB2SQL ./DB2DDL/DEPT.ddl AS DEPT;
DATASTORE kafka:///dummy_topic/
CREATE PROC P_EMP AS SELECT
{
SETURLKEY(TARGET, STRING(EMP.STATE_ABRV, EMP.EMP_NO))
REPLICATE(TARGET, EMP)
}
CREATE PROC P_DEPT AS SELECT
{
SETURLKEY(TARGET, STRING(DEPT.STATE_ABRV, DEPT.DEPT_NO))
REPLICATE(TARGET, DEPT)
}

Example 2

Partition Kafka topics using both the both the source data key and the IMS Source System Instance from the source segment change data records.

-- Define the source as IMS change data and the target as Kafka
DESCRIPTION IMSDBD ./IMSDBD/HREMPLDB.dbd AS HREMPLDB;
BEGIN GROUP IMS_SEG;
DESCRIPTION COBOL ./IMSSEG/EMPLOYEE.cob AS EMPLOYEE
          FOR SEGMENT EMPLOYEE
          IN DATABASE HREMPLDB
;
END GROUP;
DATASTORE kafka:///dummy_topic/             -- specify dynamic topic
          OF JSON                          
          AS TARGET
          DESCRIBED BY GROUP IMS_SEG       -- use source for REPLICATE
;
CREATE PROC P_EMPLOYEE AS SELECT
{
V_SOURCE_SYSTEM_INSTANCE = CONVERT_CCSID(X2C(LEFT(CDCUOW(CDCIN),8)),1208,1047)
SETURLKEY(TARGET, STRING(V_SOURCE_SYSTEM_INSTANCE,EMPLOYEE.EMP-NO))
REPLICATE(TARGET, EMP)
}