Administer > Transforming, loading, and extracting data > Overview of the mass load utilities
Resolve identifiers
XML data to be loaded into a target database must contain identifiers for XML elements that require them.
To generate or locate identifiers for catalog entities in the XML document, invoke the idresgen utility.
Before you begin
Configure the loading utilities
Procedure
- Create an XML file describing the data using either of the following ID resolution methods:
Option Description Use internal-alias ID resolution When using internal-alias resolution, an alias is substituted in place of the primary key (identifier) in the XML document. This alias is then used elsewhere in the XML file to refer to that element. This eliminates the need to know the unique indexes necessary to build the XML file. Internal aliases must be used consistently throughout the file. If an address-book ID ADDRBOOK_ID is aliased to @addrbook_1, all foreign-key references to that ID in the file must use @addrbook_1. Note that aliases are transient. They are not saved; and they cannot be used in a separate XML file without introducing the aliases again.
Use unique-index ID resolution Unique-index resolution, the default behavior of the idresgen utility, is used when there is no entry in the properties file for the table being analyzed or when there is no properties file. Unique-index resolution uses any of the specified unique indexes on a table as a means of locating the identifier. To update the contents of the database, know the unique key from the primary table in the database. You can query the database to find this out. For example, a DB2 command for retrieving a unique key can look like the following:
- db2 describe indexes for table schema.tablename show detail
- If necessary, add table names to the SUBKEYS table. For example, a DB2 command for creating an entry in the SUBKEYS table will look similar to the following:
db2 insert into SUBKEYS Values ( -1, 'mytable', 'mytable_primary_key',10000,50,0,2147483647)
The idresgen utility only resolves identifiers for a primary table. A primary table is one that is listed in the KEYS or SUBKEYS table. If it is necessary to resolve identifiers for a table that is not in KEYS or SUBKEYS, add the table to the SUBKEYS table before running the idresgen utility.
- Select an appropriate method to resolve entities.
- Use the load method to process the input file if all records in the file do not exist in the database.
- Use the update method to process the input file if all records in the file exist in the database.
- Use the mixed method to process the input file if only some records in the file exist in the database.
- Run idresgen utility.
- If there are errors, review Troubleshooting: idresgen utility.
- Resolve identifiers for records that share identifiers with existing data
If you are loading new data into a WebSphere Commerce database that shares identifiers with data that already exists in the WebSphere Commerce database, include the existing data in the XML file that you want to load. The existing data must appear before the new data in the XML file.
- Create an XML file to use internal-alias ID resolution
When using internal-alias resolution, an alias is substituted in place of the primary key (identifier) in the XML document. This alias is then used elsewhere in the XML file to refer to that element. This eliminates the need to know the unique indexes necessary to build the XML file. Internal aliases must be used consistently throughout the file. If an address-book ID ADDRBOOK_ID is aliased to @addrbook_1, all foreign-key references to that ID in the file must use @addrbook_1. Note that aliases are transient. They are not saved; and they cannot be used in a separate XML file without introducing the aliases again.
- Create an XML file to use unique-index ID resolution
- Specify a properties file with the idresgen utility
You can use an alternative Java properties file to describe which columns of a primary entry should be used as lookups for tables, which require the identifier of a primary row. This definition takes precedence over the unique index resolution method.
- Example: Loading data into the MEMBER table (idresgen utility)
The idresgen utility handles resolution for tables that have identifiers generated for them by the system. This includes any table and column registered in the KEYS or SUBKEYS table. This resolution has two components:
- Troubleshoot: idresgen utility
If errors occur while resolving identifiers, refer to the following table.
- Example: Configuring the IDResolveKeys.properties file to generate identifiers
In the following example, resolve identifiers ADDRBOOK_ID and ADDRESS_ID for ADDRBOOK and ADDRESS records respectively. The identifiers for the MEMBER records are already known. Each record requires a valid identifier for the WebSphere Commerce database. In addition, the ADDRBOOK_ID in the ADDRESS record requires the identifier from the primary table to satisfy its foreign-key constraint.
- Example: Configuring the IDResolveKeys.properties file to generate cascaded primary keys
The primary table STOREENT defines a primary key STOREENT_ID. STORE, a foreign table referencing STOREENT, defines a primary key STORE_ID that is a foreign key to the primary table STOREENT. This means that the value of STORE_ID must be one of the STOREENT_ID values. STORE_ID, the primary key of the foreign table STORE, therefore has a dual role: primary and foreign.
- Example: Configuring the IDResolveKeys.properties file to generate compound keys
A key made up of more than two columns is a compound key. You can define a compound-key lookup in the IDResolveKeys.properties file by specifying both NAMEDELIMITER and SELECTDELIMITER followed by the field names.To have the lookup criteria for ADDRBOOK records be the compound of the display name and the member ID, for example, specifying the following in the IDResolveKeys.properties file:
Related concepts
Overview of the mass load utilities
Related tasks
Configure the idresgen utility
Specify a properties file with the idresgen utility
Create an XML file to use internal-alias ID resolution
Create an XML file to use unique-index ID resolution
Related reference
Resolve identifiers for records that share identifiers with existing data
Troubleshoot: idresgen utility