EXPRESSION TRANSFORMATION

Introduction
Transformations help to transform the source data according to the requirements of target system and it ensures the quality of the data being loaded into target. The process of manipulating data. Any manipulation beyond copying is a transformation. Transformations are of two types: Active Passive

Overview

Expression transformation is used to to calculate values in a single row before you write it to the target Expressions can be used to perform calculations and also to test conditional statements before the output results are written into target tables To use the expression transformation to calculate values for a single row,We must include the following ports Input or output ports for each value used in calculation Output port for the expression

2.Creating Ports We can create a new port in the following ways 1. Drag a port from another transformation Click the add button on the Ports tab .

precision and scale Port Type Default Value Description Other Properties .we can configure the following properties Port Name Data Type.On the ports tab.

Output Ports 3. Input Ports 2. Input/Output Ports .Data passes in and out of the mapping through the folllowing ports 1.Linking Ports We link mapping objects through ports.

7.Commonly Used Date Functions in Expressions We make use of many date functions inside the expressions The important among them are the following Add_To_Date Date_Compare Date_Diff Get_Ddate_Part Is_Date Last_Day To_Date 1. 6. 5. 2. 4. 3. .

'YY'. 10 ) ADD_TO_DATE( SHIP_DATE. 14 ) . 'DD'. 10 ) ADD_TO_DATE( SHIP_DATE. 'MONTH'. 'HH'.Add_To_Date ADD_TO_DATE ( SHIP_DATE. µMI'. 10 ) ADD_TO_DATE( SHIP_DATE. 14 ) ADD_TO_DATE( SHIP_DATE. 14 ) ADD_TO_DATE( SHIP_DATE. µSS'.

. 1 if the second date is earlier. Note that DATE_COMPARE returns an integer value rather than a date value. date2 ) Return Value -1 if the first date is earlier. 0 if the two dates are equal.Date_Compare Returns an integer indicating which of two dates is earlier. Syntax DATE_COMPARE( date1.

minutes.DATE_DIFF Returns the length of time between two dates. hours. Example The following expressions return the number of hours between the DATE_PROMISED and DATE_SHIPPED ports: DATE_DIFF( DATE_PROMISED. If date1 is later than date2. DATE_SHIPPED. If date1 is earlier than date2. DATE_SHIPPED. µYYYY' ) . date2. format ) Return Value Double value. DATE_SHIPPED. days. You can request the format to be years. or seconds. Syntax DATE_DIFF( date1. µDD' ) DATE_DIFF( DATE_PROMISED. It subtracts the second date from the first date and returns the difference. the return value is a positive number. months. Zero if the dates are the same. 'HH' ) DATE_DIFF( DATE_PROMISED. DATE_SHIPPED. µMM' ) DATE_DIFF( DATE_PROMISED. the return value is a negative number.

NULL if a value passed to the function is NULL.GET_DATE_PART Returns the specified part of a date as an integer value. GET_DATE_PART returns 4. Example The following expressions return the hour for each date in the DATE_SHIPPED port. 'HH24' ) . and pass a date such as Apr 1 1997 00:00:00. format ) Return Value Integer representing the specified part of the date. if you create an expression that returns the month portion of the date. 'HH12' ) GET_DATE_PART( DATE_SHIPPED. 'HH' ) GET_DATE_PART( DATE_SHIPPED. Therefore. Note that 12:00:00AM returns 0 because the default date format is based on the 24 hour interval: GET_DATE_PART( DATE_SHIPPED. Syntax GET_DATE_PART( date.

format] Example The following expression checks the INVOICE_DATE port for valid dates: IS_DATE( INVOICE_DATE ) . A valid date is any string in the default date format of MM/DD/YYYY HH24:MI:SS IS_DATE evaluates strings and returns an integer value.IS_DATE Returns whether a string value is a valid date. Syntax IS_DATE( value [. The output port for an IS_DATE expression must be String or Numeric datatype.

 NULL if a value in the selected port is NULL. . The last day of the month for that date value you pass to this function. Syntax LAST_DAY( date ) Return Value  Date.LAST_DAY Returns the date of the last day of the month for each date in a port.

You use the TO_DATE format strings to specify the exact format of the source strings. TO_DATE always returns a date and time. . If you pass a string that does not have a time value.TO_DATE Converts a character string to a date datatype in the same format as the character string. Syntax TO_DATE( string [. The output port must be date/time for TO_DATE expressions. format] ) Return Value Date. the date returned always includes the time 00:00:00.

The most commonly used among them are the following ‡ ASCII ‡ CONCAT ‡ DECODE ‡ ERROR ‡ IIF ‡ INSTRING ‡ IS_NUMBER ‡ IS_SPACES ‡ ISNULL ‡ LENGTH ‡ LTRIM ‡ RTRIM .OTHER FUNCTIONS  We use some functions other than the date functions in expressions.

RPAD SUBSTR TO_CHAR TO_DECIMAL TO_FLOAT TO_INTEGER .

Syntax ASCII ( string ) Return Value  Integer.ASCII The ASCII function returns the numeric ASCII value of the first character of the string passed to the function. The ASCII or Unicode value of the first character in the string.  NULL if a value passed to the function is NULL .

second_string ) Return Value   String.CONCAT Concatenates two strings. you can use the || string operator to concatenate strings. . NULL if both string values are NULL. Alternatively. Syntax CONCAT( first_string. CONCAT converts all data to text before concatenating the strings.

. You can build an unlimited number of searches within a DECODE function. first_search. second_search. Default value if the search does not find a matching value. which you define. first_result [.. If the function finds the value.default] Return Value First_result if the search finds a matching value. NULL if you omit the default argument and the search does not find a matching value. second_result]. it returns a result value.[.. you can either trim trailing blanks with the RTRIM function or include the blanks in your search string. If you use DECODE to search for a value in a string port. Syntax  DECODE( value.DECODE Searches a port for a value you specify.

414213562.141592654. This expression always writes the result as a Decimal. you have the following expression: DECODE ( CONST_NAME 'Five'. 1.DECODE and Datatypes When you use DECODE. 3. You cannot create a DECODE function with both string and numeric return values.141592654.414213562. . 3. the datatype of the return value is always the same as the datatype of the result with the greatest precision. 1. and 3. 'Archimedes'. For example. 5. 'Pythagoras'. The first result is an Integer. and the other results are Decimal. The Decimal datatype has greater precision than Integer. 'Pi'.141592654 ) The return values in this expression are 5.

For example. the function returns the following when the condition is FALSE: 0 if value1 is a Numeric datatype. Empty string if value1 is a String datatype. Return Value value1 if the condition is TRUE. based on the results of a condition. the FALSE (value2) condition in the IIF function is not required. value2 if the condition is FALSE.value2] ) Unlike conditional functions in some systems. the following expression includes the FALSE condition NULL so the PowerCenter Server returns NULL for each row that evaluates to FALSE: . value1 [. Syntax      IIF( condition. NULL if value1 is a Date/Time datatype. If you omit value2.IIF Returns one of two values you specify.

the datatype of the return value is the same as the datatype of the result with the greatest precision. . you have the following expression: IIF( SALES < 100. so the datatype of the return value is always a Decimal. 1.3333 ) The TRUE result (1) is an integer and the FALSE result (. We can use nested IIFs as well. the datatype of the return value is Double. .IIF and Datatypes When you use IIF. The Decimal datatype has greater precision than Integer.3333) is a decimal. For example. When you run a session in high precision mode and at least one result is Double.

occurrence]] ) Return Value ‡ Integer if the search is successful. counting from left to right. search_value [.start [. counting from left to right.INSTR Returns the position of a character set in a string. ‡ Zero if the search is unsuccessful. Syntax  INSTR( string. ‡ NULL if a value passed to the function is NULL. . Integer represents the position of the first character in the search_value.

FALSE (0) if the value is not NULL. . Similarly we have IS_SPACES and IS_NUMBER functions. Syntax  ISNULL( value ) Return Value TRUE (1) if the value is NULL.ISNULL Returns whether a value is NULL.

LENGTH Returns the number of characters in a string. . ‡ NULL if a value passed to the function is NULL. Syntax  LENGTH( string ) Return Value ‡ Integer representing the length of the string. including trailing blanks.

‡ NULL if a value passed to the function is NULL. If the trim_set is NULL.LTRIM AND RTRIM Removes blanks or characters from the beginning or end of a string Syntax  LTRIM( string [. . trim_set] ) Return Value ‡ String. trim_set] )  RTRIM( string [. The string values with the specified characters in the trim_set argument removed. the function returns NULL.

RPAD Converts a string to a specified length by adding blanks or characters to the end of the string. ‡ NULL if a value passed to the function is NULL. .second_string] ) Return Value ‡ String of the specified length. Syntax  RPAD( first_string. or if length is a negative number. length [.

SUBSTR counts all characters. Syntax  SUBSTR( string. including blanks. ‡ Empty string if you pass a negative or zero length value.length] ) Return Value ‡ String.SUBSTR Returns a portion of a string. starting at the beginning of the string. ‡ NULL if a value passed to the function is NULL. start [. .

Syntax  TO_INTEGER( value [.TO_INTEGER Converts a string or numeric value to an integer. TO_INTEGER ignores leading spaces. We can use TO_DATE.TO_DECIMAL and TO_FLOAT just like TO_INTEGER . TO_INTEGER syntax contains an optional argument that allows you to choose to round the number to the nearest integer or truncate the decimal portion. flag] ) Return Value ‡ ‡ ‡ ‡ Integer. NULL if the value passed to the function is NULL. Zero if the value passed to the function contains alphanumeric characters.

THANK YOU .

Sign up to vote on this title
UsefulNot useful