Parameters and Variables in Informatica
Parameters and Variables in Informatica
Informatica
Aaron Gendle
2 Comments
346 Views
variable within a mapping by selecting the Parameters and Variables Mappings menu item within the
Mapping Designer.
After selecting the Parameters and Variables Mappings menu item, aDeclare Parameters and
Variables dialog box will open up.
We define the value of the parameter in a parameter file prior to running a session.
We can do this for a variable as well, but is not necessary. If we define a variables value within a
parameter file, the mapping/session will use the parameter files value as the variables initial/start
value. If we do not declare the variables value in a parameter file, the last value saved by the
session/mapping will be the variables initial/start value.
One final place the Informatica Integration Service will look for an initial value is in the Initial Value:
setting of the Declare Parameters and Variables dialog box. If a parameter has not been defined
within a parameter file, this initial value will be used as the start value. Similarly, if a variable has not
been defined within a parameter file and the Integration Service cannot find a saved variable value
within the repository.
If none of these parameter/variable initial values are set explicitly, Informatica will default a string
datatypes to an empty string, numbers to 0, and dates to 1/1/1753 A.D. or 1/1/1.
Parameter and Variable Start Value Setting Order
Parameter
Variable
Quick Tip
Most databases require a single quote around string values, so make sure to add these in any custom
SQL override statments. If $$Country is defined in a parameter file as USA for example, add single
quotes around $$COUNTRY
SELECT * FROM STATE WHERE COUNTRY = $$COUNTRY
Will become
SELECT * FROM STATE WHERE COUNTRY = USA
Summary
After reading through this post, I hope you can see the value of Parameters and Variables in
Informatica. With parameters and variables we can simplify architecture and reduce rework. There are
many more use cases for parameters and variables within Powercenter.
I invited you to share a creative way you have been able to leverage Informatica parameters and
variables!
October 1, 2014
Aaron Gendle
982 Views
2. start, defined by an integer, is merely the starting position to begin counting. We can pass a
positive or negative value here. If we pass a positive value, we count left to right for our starting
position. Conversely, if we pass a negative value, we count right to left for our starting position. The
integration service considers a 0 equal to 1, the first character in our string.
3. length is an optional parameter. If entered, it must be an integer greater than 0. It tells the
integration service how many characters of the string we want to return based on our starting position.
If left blank, the entire string will be returned from the start location specified.
Ok now that we understand the SUBSTR in Informatica syntax, lets continue our phone number
example.
Area Code
Using the below SUBSTR in Inforamtica parameter values, we can return the first three characters
from our PHONE_NUMBER data:
SUBSTR(PHONE_NUMBER, 1, 3)
PHONE_NUMBER
AREA_CODE
209-555-1234
209
714-555-5678
714
515-555-9123
515
PHONE_NUMBER
MAIN_LINE
209-555-1234
555-1234
714-555-5678
555-5678
515-555-9123
555-9123
Putting it all together, our expression transformation will produce the following:
PHONE_NUMBER
AREA_CODE
MAIN_LINE
209-555-1234
209
555-1234
714-555-5678
714
555-5678
515-555-9123
515
555-9123
Below is a snapshot of our expression transformation ports tab. I defined our new fields using
SUBSTR as OUT_AREA_CODE and OUT_MAIN_LINE.
Common Questions
Question 1 What will the SUSTR in Informatica fuction return when my string value is NULL?
A. When the string value is NULL, SUBSTR will return NULL.
Question 2 What if my string does not follow a character length pattern. How would I return the
domain names in an email address for example?
A. Many times our data is not simple. It may follow a pattern of some kind, but perhaps not as straight
forward as our PHONE_NUMBER example.
In these situations, we need to use the INSTR function to determine either our start position, length of
characters to return or both.
In the case of an email domain, we would need to do something like the below
SUBSTR(EMAIL_ADDRESS, INSTR(EMAIL_ADDRESS, @))
We passed the EMAIL_ADDRESS port into our SUBSTR string value parameter. Since we cannot
predict the starting position for every email address ahead of time, I used the INSTR function to get
my start position. I passed the same EMAIL_ADDRESS port into INSTR as the string to search in,
and then the @ symbol as the character to search for.
The INSTR function in Informatica will then return the start postion of the first occurrence of the @
symbol. Since I do not know how long any domain will be, I left the SUBSTR length optional
parameter empty so the entire domain will be returned.
Using some real data, our results might look something like this:
EMAIL_ADDRESS
DOMAIN
gmail.com
hotmail.com
yahoo.com
Summary
SUBSTR in Informatica is a very useful function. It helps us extract specific characters from a string
that might be useful on their own. The phone number use case is a perfect example of how SUBSTR
can be used on strings with simple, consistent patterns. For more complex patterns we might use the
INSTR function in Informatica to compliment SUBSTR.
Let me know how you have used the SUBSTR function in Informatica?
Expression Transformation in
Informatica
July 7, 2014
Aaron Gendle
1 Comments
1603 Views
Lets take a quick look at the different tabs within Informaticas expression transformation.
Within the transformation tab, we have the ability to rename the transformation by clicking the
Rename button and updating the name in transformation name text box. Notice how I have renamed
our the expression transformation to EXP_SALES_HIGH.
Additionally, we can type a useful transformation description, and/or make the transformation reusable
by checking the make reusable checkbox.
Port Field
Attribute Name
Description
Port Name
Datatype
Length/Precision
Scale
Input Port
Variable/Local
Port
Expression
Lets take a deeper look into the expression attribute. Notice, we can single click each fields
expression box if the field is an output or variable port. After clicking, we get the below expression
editor box. Just to provide a high level view of what we can do here, all the action will occur within the
formula box. This is where we will place all our data manipulating functions and calculations.
On the left side of our expression editor, we have functions, ports, and variables tabs. The functions
tab gives a list and functional description of the over 90 built in Informatica expression transformation
functions. The ports tab lists all available ports that can be manipulated within the expression. Finally,
the variables ports provides a list of all built in and user specified variables.
On the bottom right of the expression editor, a validate button is available to validate the formula we
have placed in the formula box. If our formula is successfully validated we will get a dialog box that
looks like this
If our formula is not parsed successfully, we will get a dialog box that looks like this
If we just click OK, our formula will automatically be validated and we will only receive an
unsuccessful message if our formula is invalid. Our expression editor will close without a message if
our formula is valid.
Finally, we have a COMMENT button that generates a comment box. This box allows us to generate
more detailed comments around each individual field within our expression.
Summary
The Expression Transformation in Informatica is one of the most common transformation in a
PowerCenter mapping. The middle portion of most mappings are all about transforming data and that
is exactly what Informaticas expression transformation was designed for. With it, we can transform
any port passed through it, one record at a time.
March 2, 2014
Ravneet Ghuman
1239 Views
Properties Tab
The properties tab below allows us to set the filter condition. The default value is True, which lets all
records through.
Common Questions
1. Where should I place filter transformation in Informatica mapping?
To improve performance of a workflow, filter out unwanted records as early as possible in the mapping
this would ensure fewer records flow through a major part of the map, thereby improving
performance.
2. Is it better to use filter conditions in Source Qualifier Transformations over a Filter Transformation in
Informatica to drop records?
Yes, set filter conditions in Source Qualifier transformations where possible. The advantage of this
approach is that it limits the number of records read from the source itself as against reading all
records and then using a filter transformation to process fewer records. However, filter conditions can
be set in Source Qualifier Transformation only for relational sources, whereas Filter transformations
can work with any source type, all it needs is a condition that returns either a True or a False.
Velocity recommends the below format when naming a Filter Transformation in Informatica mapping:
FIL_{DESCRIPTOR}
Ex: FIL_EmployeeSalary50k
Aaron Gendle
1317 Views
Lets take a deeper look at what I am talking about. Below is an example of a single source of sales
data being passed through a router transformation.
Within the router transformations group tab (see below) I created three different output groups:
SALES_HIGH, SALES_MEDIUM, and SALES_LOW. Within each group filter condition field, I coded
some conditional logic. This logic will check for the amount of sales of each sales agent record
passed through the transformation. If a given record meets the conditional logic for a group, it will be
passed down its data path, through its output ports, to one of the three distinct expressions connected
to the router.
For example, lets assume sales agent John Smith has a total sales of $11,594.54. This record would
be meet the condition for HIGH_SALES and continue to EXP_HIGH_SALES since 11,594.54 is
greater than 10,000.00.
As previously mentioned, this same functionality can be accomplished with multiple filter
transformations as seen below. We could do this by creating three different filter transformations and
adding each individual group output filter logic to our three distinct filters.
TOTAL_SALES <= 4000 instead of 5000. This change would redirect any record with a total sales
from 4001 to 5000 to the DEFAULT port. We could then decide if we wanted to route these DEFAULT
port records to an additional data path/target or just let them get filtered out of our mapping
completely.
July 3, 2014
Aaron Gendle
2620 Views
is vital in the data integration/warehousing world to have this control as it allows us to store data in a
manner that fits our business need.
This tab will show us a treat source rows as drop down with four different options. This attribute
allows us to control, at a session level, if rows are inserted, updated, or deleted from our target
table(s). If we select insert, our mapping will attempt to insert each record directed to our target table.
We need to ensure our data includes a primary key mapped to our target tables primary key. If for
some reason we attempt to insert a record with a primary key that already exists in our target table,
this record will be rejected. These same rules apply to update and delete options. The difference
being, our mapping records will attempt to be updated or deleted in our target table instead of
inserted.
In addition to selecting the correct treat source rows as attribute option, we must set target table
level attributes on the mapping tab of our session. If for example we have selected the insert option
for our treat source rows as option, we need to click on our target table, then check the insert
attribute checkbox. Make sure to uncheck all other database operation checkboxes.
If we want to update records and have selected update as our treat source rows as attribute option,
then we have three options at the target table level to choose from: Update as Update, Update as
Insert, and Update else Insert.
Attribute
Value
Update as
Update
Update as
Insert
Update else
Insert
Similarly to our treat source rows as insert example, if we want to delete rows, we should select
delete as our treat source rows as attribute option and check the delete attribute checkbox for each
target table on the mapping tab.
Our last table attribute option is the truncate target table option. This will truncate all data within the
target table prior running any records through our mapping.
Our final treat source rows as attribute option is data driven. This is the default option when we add
an update strategy transformation in our mapping. This option tells our mapping to use the logic within
our update strategy transformation when determining whether to insert, update, delete or reject
records. This finer control is very nice to have when building a data warehouse and a best practice
when flagging records for the same target table with different database operations.
Configuring the Mapping
Lets take a look at how to configure our update strategy transformation in an Informatica mapping.
Below we have an example mapping M_Sales.
Notice we have a single source of sales agent data coming from a flat file. Our data is being routed
through a router transformation, then to 3 different update strategy transformations
(UPD_INSERT_HIGH, UPD_UPDATE_MEDIUM, and UPD_DELETE_LOW), all flagging our records
for different database operations. Finally we are sending our sales agent records to the same target
table, SALES.
Lets take a quick look at our group router criteria
Notice how our filter condition separates agents with high, medium, and low total sales amounts. We
are routing agents with high sales to UPD_INSERT_HIGH update strategy transformation, medium
sales to UPD_UPDATE_MEDIUM update strategy transformation, and low sales to
UPD_DELETE_LOW update strategy transformation. Lets take a look at each of these
transformations in more detail.
In the mapping, double clicking on the UPD_INSERT_HIGH update strategy transformation and
clicking on the properties tab, we get the below view.
Notice how I have programmed DD_INSERT into the update strategy expression transformation
attribute. This tells the transformation to flag all records passed through it, for insert into the target
table. We can also use numeric values here, but I would recommend using the constants as a best
practice since the operation is much more intuitive. Below are all of our options for this attribute along
with their corresponding operations.
Operation
Constant
Numeric Value
Insert
DD_INSERT
Update
DD_UPDATE
Delete
DD_DELETE
Reject
DD_REJECT
Lets quickly review our two additional update strategy transformation in this mapping.
UPD_UPDATE_MEDIUM is set to update rows it matches on by primary key in our target SALES
table.
UPD_DELETE_LOW is set to delete rows it matches on by primary key in our target SALES table.
Notice how the forward rejected rows transformation attribute is checked. This is the default setting for
a new update strategy transformation. This really didnt come into play in our example, but if we were
to set some conditional logic within our update strategy expression, we might reject some rows and
decide we do not want them to pass to our next transformation. For example, we could put a
statement like the below in our UPD_UPDATE_MEDIUM update strategy transformation:
IIF ( TOTAL_SALES <= 10000 AND TOTAL_SALES > 6000, DD_UPDATE, DD_REJECT)
This statement would instruct the transformation to flag rows for update if TOTAL_SALES was less
than our equal to 10000 and greater than 6000. However, if TOTAL_SALES was less or equal to
6000, then we would reject the update. This actual logic may not actual be something we would do in
real life, but I think you get the point.
Back to our forward rejected rows attribute, if we leave the checkbox unchecked, these records would
not pass to our target table and would be dropped by the Integration Service. Additionally, they would
get written the session log file.
If keep the forward rejected rows attribute checked, not much would change. The records would get
passed to the target table, but would still be rejected and dropped. However the records would be
written to the session reject file instead of the session log file.
Summary
The Update Strategy Transformation in Informatica is a great tool to control how data passed
through a mapping is flagged for insert, update, delete, and reject in the target database table. We
can control this at either a mapping session level or a mapping level through the transformation itself.
If your in the business intelligence and data warehouse world, you will definitely want a deep
understanding of how the Update Strategy Transformation in Informatica works. Happy integrating
Aaron Gendle
683 Views
Business Purpose
The Source Qualifier Transformation in Informatica provides an efficient way to filter input
fields/columns. Many times we do this through performing homogeneous joins, a join made on the
same data source (Ex: Oracle + Oracle, DB2 + DB2, Teradata + Teradata).
Properties Tab
Property
Description
SQL Query
User
Defined
Join
Source
Filter
Number of
Sorted
Ports
Select
Distinct
Pre SQL
Post SQL
Summary
The Source Qualifier Transformation in Informatica helps us select records from flat files and
relational database sources. In my experience, the SQL Query property is heavily used to code
custom SQL statements. These simple to complex custom SQL statements help us extract specific
data according to our individual mapping needs.