The SETURL function can be used to specify the full CDC:///url when a combination of literal text prefixes, suffixes and source descriptions aliases will not meet requirements to be used when writing to a Kafka Target. For more information, see Kafka Datastores.
Note: SETURL cannot be used to override a generic URL (a URL that contains an asterisk in the topic name position). Beginning in 4.1.37, a runtime error message for SETURL was generated. For more information, see SQDE017E.
Category
Specialized
Syntax
SETURL(<target_datastore>, 'kafka:///<url_string>[/<partition> |/key |/root_key |/]')
Parameter and Description
Parameter | Description |
---|---|
kafka:///<url_string>[/<partition> |/key |/root_key |/]' | The url_string may consist of any combination of literals, variables, source alias references and source data concatenated to create a Kafka topic URL. While the trailing /<partition> |/key |/root_key |/ is optional, one must be specified as a placeholder if the SETURLKEY function is also used and a single / is recommended. Note: The restrictions on the use of a final
/ or /key or /rootkey in the URL apply whether the URL appears on a DATASTORE statement or in a SETURL statement. |
Example
Construct Kafka URL's using more descriptive topics.
DESCRIPTION DB2SQL ./DB2DDL/EMP.ddl AS EMP
DESCRIPTION DB2SQL ./DB2DDL/DEPT.ddl AS DEPT
KEY IS DEPT_NO;
DATASTORE kafka:///key
...
Used with the following logic in the Apply Engine script:
CREATE PROC P_EMP AS SELECT
{
SETURL(TARGET, 'kafka:///cdc_EMPLOYEE_db2/key')
REPLICATE(TARGET, EMP)
}
CREATE PROC P_DEPT AS SELECT
{
SETURL(TARGET, 'kafka:///cdc_DEPARTMENT_db2/key')
REPLICATE(TARGET, DEPT)
}