HOW TO: Insert record to KEYS table via WCBD

After creating custom tables for WCS that has its own primary key, we would need to register that primary key into the KEYS table.  Often times, we would just create an SQL statement to insert the record.  This would require you to hard code the KEYS.KEYS_ID of your custom tables.

If you don’t like to hard code they key_id, you can use the built in idresolve & massload tool that comes with WCS.  Here’s one way to do it via WCBD:

1. First we need to enable WCS to be able to resolve the keys_id.  We do this by inserting a record in the keys table.

INSERT INTO KEYS (KEYS_ID, TABLENAME, COLUMNNAME, COUNTER) VALUES (0, 'keys', 'keys_id', 100)

2. Create your StoreData.xml (should be created under DataLoad project, under xml/common folder) to be something like this.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE import SYSTEM "wcs.dtd">
<import>
  <keys keys_id="@keys_id_tableName" tablename="tableName" columnname="tableName_id" counter="0" prefetchsize="100" upperbound="9223372036850000000" /> 
</import>

where tableName is the name of your custom table and tableName_id is the table’s primary key.