In this article we are going to explain, How to achieve Informatica Update Strategy using Session Properties. Or, the steps involved in configuring the Session Properties to achieve the Update Strategy without using any Update Strategy Transformation with example.
In Informatica, you can use the Session Properties to achieve the update strategy. But, this approach is one of the worst approach in real-time. Because, instead of Lookup this will blindly update existing records (even there is no change), or insert each and every record. This approach is fine for the small table.
For this example, we are going to use the below show data (Employee Duplicate table)
And the destination table is:
As you can that the destination table has 1 record, and two extra columns. These extra columns will help you to understand the problems you might face in this approach.
Informatica Update Strategy using Session Properties
Before we start configuring the Session Properties, First let me connect with the Informatica repository service. In order to do so, we have to provide the Informatica Admin Console credentials. So, Please provide the appropriate Username and Password, and click the Connect button.
TIP: Here you have to provide the Admin Username and password that you specified while installing the Informatica Server.
Step 1: Create Source Definition
Once you connected successfully, Please navigate to Source Analyzer and define your Sources. In this example, we are using [Employee Duplicate] table from SQL Server database as our source definitions. Please refer Database Source in Informatica to understand the steps involved in creating source definition
Step 2: Create Target Definition
Please navigate to Target Designer and define the Target. In this example, we are using the already created SQL table (Employee Dup) as our target definition. Please refer Create Informatica Target table using Source Definition to understand the steps involved in creating target definition
Step 3: Create a Mapping
To create a new mapping, Please navigate to Mappings menu in Menu Bar, and select the Create.. option.
This will open the Mapping Name window to write unique name for this mapping. Let me write m_update_with_session and click OK button.
TIP : Please refer Informatica Mapping article to understand the procedure to create Mapping
Drag and drop the Employee Duplicate source definitions from Sources folder to the mapping designer. Once you drag the source, Power Center designer will automatically create the source qualifier for you. I suggest you to refer Source Qualifier Transformation article.
Next, create a Expression Transformation, and Drag all the fields from Source Qualifier to Expression Transformation. I Suggest you to refer Expression Transformation article for better understanding.
Double click on the Expression transformation to add new fields, or write to custom expressions. From the below screenshot you can observe that, We added 2 new columns using the New Port button. We are going to use these new columns to store the Created Date and Modified Date
Let us write the custom expression. To do this, Click on the arrow button besides the CreatedOn.
TIP: All these new columns are output ports. So, please check mark O
This will open the Expression Editor to write custom expression. Here, we want the system date so, write SYSDATE.
From the below screenshot you can observe that, We did the same for the UpdatedOn column
Next, Drag and drop the target definition from Targets folder to the mapping designer, and connected the Expression transformation with the target definition. Please use the Autolink.. option to connect them.
Before we close the Mapping, Let us validate the mapping by going to Mapping Menu bar and selecting the Validate option.
Step 4: Create a Workflow
After we finish creating the Mapping, we have to create a workflow for it. Power Center Workflow manager provides two approaches to create workflow.
In this example we will create the Workflow manually. To do so, Please navigate to Workflows Menu and select the Create option.
This will open Create Workflow window as shown below. Please provide the unique name (wf_update_using_session) and leave the default settings.
Once we created the workflow, our next step is to create session task for our mapping.
Step 4(a): Create a Session
There are two types of sessions in informatica:
For this example we will create a Non-reusable Session. In order to create the same, Please navigate to Tasks Menu and select the Create option as shown below.
Please provide a unique name for this session. Here, we are naming it as s_update_using_session. Once you click on the Create button, a new window called Mappings will be opened. Here, we are selecting the m_update_with_session
Double click on the Session task will open the Edit Tasks window. Within Properties Tab
$Source connection value: This property will store the relational source information in $Source variable. So, click on the Arrow we marked below, and select the SQL Tutorial as the source information.
$Target connection value: This property will store the relational target information in $Target variable. So, click on the Arrow we marked below, and select the SQL Test target as the Target information.
Treat Source Rows as : Change the default Insert to Update. It means, instead of performing only insertion, it will perform update too.
Within the mappings tab, we have to configure the Source, target Connections. First, let us configure the source connections by clicking on the SQ_EmployeeDuplicate source present in the Sources folder.
With in the Connections, click on the Arrow button beside the Relational type, and use the Connection variable that we created in our previous step i.e., $Source
Now, we have to configure the Target Connection. So, click on the EmployeeDup present in the Targets folder. With in the Connections, click on the Arrow button beside the Relational type, and use the Connection variable $Target
Next, check mark the Update else Insert.
Please link the Start Task and the session task.
Next, navigate to Workflows Menu and select the Validate option to validate the Workflow. Now, Let me start the Workflow. To do so, navigate to Workflows menu, and select the Start Workflow option.
Once you select the Start Workflow option, Informatica PowerCenter Workflow monitor will be opened to monitor the workflow. From the below screenshot you can observe that, our workflow is executed without any errors.
Let us open the SQL Server Management Studio to check whether we successfully performed the update strategy. If you look at the first record, this record is updated along with the insertion. In a simple language we can say, this approach is simply replacing all the existing target table records with the source table records.
Let me update Yearly Income for EmpID 3 and add one more record.
From the below screenshot you can observe that, our workflow is executed without any errors.
As you can see, again all the records are inserted freshly.
Thank You for visiting Our Blog