Q) How to generate or load values in to the target table based on a column value using informatica etl tool.
I have the products table as the source and the data of the products table is shown below.
Now create informatica workflow to load the data in to the target table?
Solution:
Follow the below steps
I have the products table as the source and the data of the products table is shown below.
Table Name: Products Product Quantity ----------------- Samsung NULL Iphone 3 LG 0 Nokia 4Now i want to duplicate or repeat each product in the source table as many times as the value in the quantity column. The output is
product Quantity ---------------- Iphone 3 Iphone 3 Iphone 3 Nokia 4 Nokia 4 Nokia 4 Nokia 4The Samsung and LG products should not be loaded as their quantity is NULL, 0 respectively.
Now create informatica workflow to load the data in to the target table?
Solution:
Follow the below steps
- Create a new mapping in the mapping designer
- Drag the source definition in to the mapping
- Create the java transformation in active mode
- Drag the ports of source qualifier transformation in to the java transformation.
- Now edit the java transformation by double clicking on the title bar of the java transformation and go to the "Java Code" tab.
- Enter the below java code in the "Java Code" tab.
if (!isNull("quantity")) { double cnt = quantity; for (int i = 1; i <= quantity; i++) { product = product; quantity = quantity; generateRow(); } }

- Now compile the java code. The compile button is shown in red circle in the image.
- Connect the ports of the java transformation to the target.
- Save the mapping, create a workflow and run the workflow.
No comments:
Post a Comment