A mapping is a set of source and target definitions linked by transformation objects that define the rules for data transformation. Mappings represent the data flow between sources and targets. When the Integration Service runs a session, it uses the instructions configured in the mapping to read, transform, and write data.Every mapping must contain the following components:
- Source definition : Describes the characteristics of a source table or file.
- Transformation : Modifies data before writing it to targets. Use different transformation objects to perform different functions.
- Target definition : Defines the target table or file.
- Understand the Designer’s Mapping Designer tool
- Create a mapping using
- A Source definition
- Source Qualifier and Expression Transformation
- A Target definition
- Edit Transformations
- Add new ports in transformations
- Add formulas in the Expression transformation
- Validate a mapping
- Understand Designer’s Output window
I. Source Qualifier Transformation
- Select TOOLS | MAPPING DESIGNER, or click on the icon. The workbook changes to the Mapping Designer.
- Select MAPPINGS | CREATE, or click the Create Mapping icon from the Mapping toolbar.
- Enter M_Employee_Name_x for the new mapping name.
- Click on OK.
- Drag the source from the navigator to the Mapping Designer. Designer creates the Source Qualifier by default, and connects it to the source as shown below:
- If the Source Qualifier transformation does not appear by default, Select TOOLS | OPTIONS and click on the FORMAT tab. Ensure automatic creation by checking the ‘Create Source Qualifiers When Opening Sources checkbox’.
- Drag the source again into the workspace. The Source Qualifier transformation automatically appears and is connected to the source. Delete the previously dragged source from the workspace by pressing the delete key.
Note: Use the automatic Source Qualifier creation when you want to create one Source Qualifier for each source in your mapping and disable the automatic creation when you want to join data from different sources.
II. Edit the Source Qualifier Transformation
- Use either of the methods to invoke the Edit Transformations box.
- Right click on the Source Qualifier and select Edit…
- Double click on the Source Qualifier transformation.
- Click on the Transformation tab and click on Rename to rename the transformation.
- Enter the name and click on OK.
III. Create the Expression Transformation and link to the Source Qualifier
- To create the Expression Transformation, use either of following methods:
- Select TRANSFORMATION | CREATE.
- In the Create Transformation Dialog box, select the type of transformation from the pull-down list. Enter a name for the transformation.
- Click on the Create button.
- Click on the Done button.
Note: The expression transformation appears in normal mode.
- Link the ports from the SQ_Employees_x to the new expression transformation using any of the methods
- Select LAYOUT | LINK COLUMNS.
- Select the Link Columns icon in the toolbar Hint: Hold down the Ctrl or Shift key and select the ports in the SQ_Employees_x. Drag them to an empty line on the expression transformation. When the mouse is released, not only will the port names (including data types, precision and scale) will be copied from SQ_Employees_x, but links connecting the ports between the two transformations will also be created.
IV. Edit Expression Transformation
- Double click on the header of the Expression transformation to enter Edit mode.
- Click the Rename button under the Transformation tab.
- Rename the transformation as Exp_Employee_Name_x.
Note: If the transformation was created via the TRANSFORMATION | CREATE menu instead of the transformation toolbar, the object will have a name.
- Click on the Ports tab.
- Disable the output ports for FIRSTNAME and LASTNAME by removing the checkmark in the ‘O’ (output) column – this will define the port as input only.
- Select the FIRSTNAME port and click on the icon to add a new port and rename it to Name. This will cause the new port to be positioned immediately after FIRSTNAME.
- Verify whether the data type is string and increase the precision to 51.
- Disable the input port for NAME by removing the checkmark in the ‘I’ (input) column- this will define the port as output only.
- The Edit Transformations box should look as shown below.
V. Create Expression Formula
- Click the down arrow in the expression column of the NAME port.
- Delete the text NAME in the Formula field in the Expression Editor.
- Select the Ports tab as shown in the figure below.
- Double-click on the port LASTNAME and note its presence in the Formula field. Based on which port is selected, the port details appear under the ‘Instance Name:’ section of the ports tab.
- Create the expression as shown below:
- Click on Validate. This will parse the expression.
- Click on OK if the expression is successfully parsed.
- Click OK to close the Edit Transformation dialog box.
- The finished transformation will look like the following:
VI. Link Expression Transformation and Target
- Drag the target definition from Navigator Window into the workspace.
- Link columns of the Expression Transformation to the target definition:
- Select LAYOUT | AUTOLINK.
- In the Autolink dialog box, select the From Transformation and To Transformation.
- Click on Apply Now and OK.
- Notice the links between expression transformation and target table.
- The mapping is now complete and should look like the figure shown below:
- Select MAPPINGS | VALIDATE to validate the mapping.
- Select REPOSITORY | SAVE or press Ctrl-S to save the changes to the repository.
Note : Every time a repository save is executed, a series of validation checks are performed on what has been changed.
- View the results of the Validation by locating Save tab of the Output window, at the bottom of Designer. Note: If the Validation results show ‘INVALID’, locate the last time stamp when the save repository was executed and scan for the first error. The series of validation checks will display all of the errors. Rectify the errors and validate the mappings again, until the mapping is valid.
In this demonstration video tutorial we will see how the mapping is created.
Hope you enjoy this tutorial, Please let us know if you have any difficulties in trying out these exercise.