Users Online

· Guests Online: 151

· Members Online: 0

· Total Members: 188
· Newest Member: meenachowdary055

Forum Threads

Newest Threads
No Threads created
Hottest Threads
No Threads created

Latest Articles

Informatica Sessions & Mappings

Command Task in Informatica

The Command Task in Informatica is used to run Unix or Shell commands during the Workflow. You can use this Task to Move, Copy, or Remove files after the data is loaded, etc. In this article, we will show you how to use the Command Task in Informatica with an example.

For this Informatica Command Task example, we are going to use the below show text file data (Employee table). From the below screenshot, you can see that the Source table has 15 records  

 

Command Task in Informatica 1

And the Destination table is Employee File. As you can see, it is an Empty table

   Command Task in Informatica 2

Command Task in Informatica Example

Before we start configuring the Command Task in Informatica to Load Data from Flat File to SQL Server. First, let me connect with the Informatica repository service. To do so, we have to provide the Admin Console credentials. So, Please provide the appropriate Username and Password specified while installing the Server.

Step 1: Create Source Definition for Informatica Command Task

Once you connected successfully, Please navigate to Source Analyzer to define your Sources. As we said before, we are using the Employee table present in the local File System as our source definitions. So, Please navigate to Source menu and select the Import from File.. option  

 

Command Task in Informatica 3

Once you choose the Import from File.. option, a new window called Open Flat File will open. Please select the Employee.txt file from your local file system and click the Open button. I suggest you refer Flat File Source article to understand the following steps.

Command Task in Informatica 4

From the below screenshot you can observe that, you can see our newly created Flat File source.

Command Task in Informatica 5

TIP: We already explained the steps involved in importing a Text file in our previous article. So, Please refer to Flat File Source to understand the same. 

 

Step 2: Create Target Definition for Command Task in Informatica

Please navigate to Target Designer to define the Informatica Command Task Target. In this example, we are using the existing SQL table (Employee File) as our target definition. You can refer to Create a Target Table to understand the process of creating a target definition

Command Task in Informatica 6

Step 3: Create Mapping for Command Task in Informatica

To create a new mapping, Please navigate to Mappings menu in Menu Bar, and select the Create.. option.

 Command Task in Informatica 7

Once you select the Create.. option, a new Mapping Name window will open. Let me provide m_SQLEmp as the mapping name and click the OK button.

 Command Task in Informatica 8

Drag and drop the Employee source definitions from the Flat File Sources folder to the mapping designer. Once you drag the source, the Power Center designer automatically creates the Source Qualifier Transformation for you

Command Task in Informatica 9

Next, Drag and drop the target definition (Employee File) from the Targets folder to the mapping designer. Next, connect the source qualifier with the target definition using the Autolink.. option.

Command Task in Informatica 10

Before we close the Mapping, Let us Save, and Validate the mapping by going to Mapping Menu bar, and select the Validate option. 

Step 4: Create a Workflow for Command Task in Informatica

After we finish creating the Informatica Command Task Mapping, we have to create the workflow for it. PowerCenter Workflow manager provides two approaches to create a workflow.

In this Informatica Command Task example, we will create the Workflow manually. To do so, Please navigate to Workflows Menu and select the Create option.

Command Task in Informatica 11

It will open the Create Workflow window. Please provide the unique name (wf_CommandEx) and leave the default settings. 

Command Task in Informatica 12

Once we created the workflow, our next step is to create a session task for our mapping.

Step 4(a): Create a Session for Command Task in Informatica

There are two types of sessions:

For this Informatica Command Task example, we created a Non-reusable Session. To create Non-reusable Session, Please navigate to Tasks Menu and select the Create option. 

Command Task in Informatica 13

Please provide a unique name for this Session. Here, we are naming it as s_CommandEx. Once you click on the Create button, a new window called Mappings opened. Here you have to select the Mapping that you want to associate with this Session, i.e., m_CommandEx.

 Command Task in Informatica 14

Double click on the Session task will open the Edit Tasks window. Within the mappings tab, we have to configure the Source and Target Connections. First, let us configure the Target connection by clicking on the EmployeeFile.

Within the Connections, click on the Arrow button beside the Relational type, and Select the Target Database (Target)  

 

Command Task in Informatica 15

Now, we have to configure the Source Connection. Please click on the SQ_Employee present in the Sources folder.

  
  • Source File directory: It will use the default directory, but you can change the directory by giving the full path.
  • Source filename: It will automatically detect. If not, please specify the file name along with the extension.
Command Task in Informatica 16

Next, navigate to Workflows Menu and select the Validate option to validate the Informatica Command Task Workflow.

Command Task in Informatica 17

Step 4(b): Create a Command Task in Informatica

To create an Informatica Command Task, First, go to the Task Developer Tab. Next, navigate to Tasks Menu and select the Create option.  

 

Command Task in Informatica 18

Once you select the Create option, a new window called Create Task will open. First, select the Command Task, and provide a unique name for this Task and click on the Create button. Here, we are naming it as cmd_CopyFile.

Command Task in Informatica 19

Click on the Create button will create a Command task for you

Command Task in Informatica 20

Double click on the Informatica Command Task will open the following window. Within the General Tab, we can rename the Command Task to a more meaningful name. Please do not forget to provide a valid description of the Task. 

 

Command Task in Informatica 21

Within the Properties Tab, there is one property called :

  • Fail Parent if this task fails: Please check mark this option. If this Command Task fails, then it will fail the workflow.  
Command Task in Informatica 22

Within the Commands Tab, you have to provide the command that you are going to use in this workflow. Please click on the New button to add a new command

Command Task in Informatica 23

We renamed the field as the Copy Command. Next, click on the Arrow to add the command

Command Task in Informatica 24

It opens a space to write your command. For this example, we are using the Copy command to copy the Employee File from Source Files to target files

Command Task in Informatica 25

Next, navigate to Workflows Menu and select the Validate option to validate the Workflow.

If you observe the Workflow, First, we are starting the Workflow. Next, it will run the Session task to load data from the text file to the SQL table. Once the data transferred, the Informatica Command Task will copy Employee File from Source to target

Command Task in Informatica 26

Now, Let me start the Workflow. To do so, navigate to the Workflows menu and select the Start Workflow option.

Command Task in Informatica 27

Let us open the SQL Server Management Studio and write the following SQL Query.

Command Task in Informatica 28

Now you can see the Employee file in the default target location. 

 

Command Task in Informatica 29

Command Task in Informatica Example 2

Instead of creating a Separate command task, you can also apply the functionality within the Informatica Session Task. Let me remove the Command task from the workflow to demonstrate the same.

Command Task in Informatica 30

Double click on the Session task, and go to the Components tab

  • Pre-Session Command: This command executed before the Session
  • Post-Session Command: This command executed after the Session complete
  • Post-Session Failure Command: It executes if the session task fails
Command Task in Informatica 31

For this example, we are going to create a command that has to execute after the Session is complete (Post-Session). Under the Type drop-down, we have three options. Let me select the Non-reusable command

Command Task in Informatica 32

Click on the New field

Command Task in Informatica 33

Next, click the Arrow field to write a command

Command Task in Informatica 34

For this example, we are using the Move command to move the Employee File from Source Files to target files

Command Task in Informatica 35

Let me run the Informatica Command Task Workflow and see. As you can see, there is no Employee under the Source folder

Command Task in Informatica 36

And the destination folder has this employee file

Command Task in Informatica 37

 

 

 

 

Comments

No Comments have been Posted.

Post Comment

Please Login to Post a Comment.

Ratings

Rating is available to Members only.

Please login or register to vote.

No Ratings have been Posted.
Render time: 0.83 seconds
10,810,774 unique visits