Sequence Generator Transformation Example
The following example shows how you can use the Sequence Generator transformation to generate primary keys.
You are gathering customer data and need to assign customer IDs to each customer. The CustomerData.csv flat file contains your source customer data. You create a mapping that includes the Sequence Generator transformation to create customer IDs, using the following process:
- 1. You create a copy of the CustomerData.csv file to use as the target and then add the cust_id field to the file to hold the generated customer ID values. You name the file CustomerData_IDs.csv.
- 2. You create a connection that has access to the CustomerData.csv and CustomerData_IDs.csv files.
- 3. You create a mapping in the Mapping Designer and add a Source transformation to the mapping. You configure the transformation to use the CustomerData.csv file.
- 4. You add a Sequence transformation to the mapping.
- 5. You want a simple sequence starting with 1, so on the Sequence tab, you set the Initial Value to 1 and the Increment By value to 1. This setting starts the sequence at 1 and increments the value by 1, for example 1, 2, 3.
You leave the default values for the other properties.
- 6. You add a Target transformation to the mapping and configure the transformation to use the CustomerData_IDs.csv file that you created. You connect the Source transformation and the Sequence Generator transformation to the Target transformation.
- 7. In the Target transformation, you map the NEXTVAL output field to the cust_id field.
- 8. You save the mapping and create a Mapping Configuration task in the Mapping Configuration Task wizard. The Current Value is 1 because you have not run the mapping yet and the initial value is 1.
- 9. You open the task in the Activity Log to view the job details. The Mapping Configuration Job Details page shows that numbers were generated for 273 rows. The Next Value is 274, which means the next time you run the mapping, the sequence will begin with 274.
- 10. You open the CustomerData_IDs.csv file and note that the cust_id field is populated with a numeric sequence.