Informatica Transformations Ans SQL Queries PDF Free
Informatica Transformations Ans SQL Queries PDF Free
1. What is a transformation?
10. How do you promote a non-reusable
A transformation is a repository object that
transformation to reusable transformation?
generates, modifies, or passes data.
Edit the transformation and check the Make
Reusable option
2. What is an active transformation?
An active transformation is the one which
11. How to create a non-reusable instance of
changes the number of rows that pass through
reusable transformations?
it.
In the navigator, select an existing
Example: Filter transformation
transformation and drag the transformation into
the mapping workspace. Hold down the Ctrl key
3. What is a passive transformation?
before you release the transformation.
A passive transformation is the one which does
not change the number of rows that pass
12. Which transformation can be created only as
through it.
reusable transformation but not as non-reusable
Example: Expression transformation
transformation?
External procedure transformation.
4. What is a connected transformation?
A connected transformation is connected to the INFORMATICA INTERVIEW QUESTIONS ON
data flow or connected to the other AGGREGATOR TRANSFORMATION
transformations in the mapping pipeline.
1. What is aggregator transformation?
Example: sorter transformation
Aggregator transformation performs aggregate
calculations like sum, average, count etc. It is an
5. What is an unconnected transformation?
active transformation, changes the number of
An unconnected transformation is not connected
rows in the pipeline. Unlike expression
to other transformations in the mapping. An
transformation (performs calculations on a row-
unconnected transformation is called within
by-row basis), an aggregator transformation
another transformation and returns a value to
performs calculations on group of rows.
that transformation.
Example: Unconnected lookup transformation,
2. What is aggregate cache?
unconnected stored procedure transformation
The integration service creates index and data
cache in memory to process the aggregator
6. What are multi-group transformations?
transformation and stores the data group in
Transformations having multiple input and
index cache, row data in data cache. If the
output groups are called multi-group
integration service requires more space, it stores
transformations.
the overflow values in cache files.
Examples: Custom, HTTP, Joiner, Router,
Union, Unstructured Data, XML source qualifier,
3. How can we improve performance of
XML Target definition, XML parser, XML
aggregate transformation?
generator
Use sorted input: Sort the data before
7. List out all the transformations which use passing into aggregator. The integration service
cache? uses memory to process the aggregator
Aggregator, Joiner, Lookup, Rank, Sorter transformation and it does not use cache
memory.
8. What is blocking transformation? Filter the unwanted data before
Transformation which blocks the input rows are aggregating.
called blocking transformation. Limit the number of input/output or
Example: Custom transformation, unsorted output ports to reduce the amount of data the
joiner aggregator transformation stores in the data
cache.
9. What is a reusable transformation?
A reusable transformation is the one which can
4. What are the different types of aggregate
be used in multiple mappings. Reusable
functions?
transformation is created in transformation
The different types of aggregate functions are INFORMATICA INTERVIEW QUESTIONS ON
listed below: EXPRESSION TRANSFORMATION
AVG,COUNT,,FIRST,LAST,MAX,MEDIAN,MIN,
1. What is an expression transformation?
PERCENTILE,STDDEV,SUMVARIANCE
An expression transformation is used to
5. Why cannot you use both single level and calculate values in a single row.
nested aggregate functions in a single Example: salary+1000
aggregate transformation?
2. How to generate sequence numbers using
The nested aggregate function returns only one expression transformation?
output row, whereas the single level aggregate Create a variable port in expression
function returns more than one row. Since the transformation and increment it by one for every
number of rows returned are not same, you row. Assign this variable port to an output port.
cannot use both single level and nested
aggregate functions in the same transformation. 3. Consider the following employees data as
If you include both the single level and nested source?
functions in the same aggregator, the designer
marks the mapping or mapplet as invalid. So, Employee_id, Salary
you need to create separate aggregator 10, 1000
transformations. 20, 2000
30, 3000
6. Up to how many levels, you can nest the 40, 5000
aggregate functions?
Q1. Design a mapping to load the cumulative
We can nest up to two levels only. sum of salaries of employees into target table?
Example: MAX( SUM( ITEM ) ) The target table data should look like as
Employee_id, Salary, Cumulative_sum
7. What is incremental aggregation? 10, 1000, 1000
20, 2000, 3000
The integration service performs aggregate 30, 3000, 6000
calculations and then stores the data in historical 40, 5000, 11000
cache. Next time when you run the session, the
integration service reads only new data and Q2. Design a mapping to get the pervious row
uses the historical cache to perform new salary for the current row. If there is no pervious
aggregation calculations incrementally. row exists for the current row, then the pervious
row salary should be displayed as null.
8. Why cannot we use sorted input option for The output should look like as
incremental aggregation? Employee_id, Salary, Pre_row_salary
10, 1000, Null
In incremental aggregation, the aggregate
20, 2000, 1000
calculations are stored in historical cache on the
30, 3000, 2000
server. In this historical cache the data need not
40, 5000, 3000
be in sorted order. If you give sorted input, the
records come as presorted for that particular run
4. Consider the following employees table as
but in the historical cache the data may not be in
source
the sorted order. That is why this option is not
allowed. Department_no, Employee_name
9. How the NULL values are handled in 20, R
10, A
Aggregator?
10, D
20, P
You can configure the integration service to treat
10, B
null values in aggregator functions as NULL or
10, C
zero. By default the integration service treats
20, Q
null values as NULL in aggregate functions.
20, S
Q1. Design a mapping to load a target table with Q2. Design a mapping to get the pervious row
the following values from the above source? salary for the current row. If there is no pervious
row exists for the current row, then the pervious
Department_no, Employee_list row salary should be displayed as null.
10, A The output should look like as
10, A,B
10, A,B,C employee_id, salary, pre_row_salary
10, A,B,C,D 10, 1000, Null
20, A,B,C,D,P 20, 2000, 1000
20, A,B,C,D,P,Q 30, 3000, 2000
20, A,B,C,D,P,Q,R 40, 5000, 3000
20, A,B,C,D,P,Q,R,S
Solution:
Q2. Design a mapping to load a target table with
the following values from the above source? Connect the source Qualifier to expression
transformation. In the expression transformation,
Department_no, Employee_list create a variable port V_count and increment it
10, A by one for each row entering the expression
10, A,B transformation. Also create V_salary variable
10, A,B,C port and assign the expression
10, A,B,C,D IIF(V_count=1,NULL,V_prev_salary) to it . Then
20, P create one more variable port V_prev_salary
20, P,Q and assign Salary to it. Now create output port
20, P,Q,R O_prev_salary and assign V_salary to it.
20, P,Q,R,S Connect the expression transformation to the
target ports.
INFORMATICA SCENARIO BASED
In the expression transformation, the ports will
QUESTIONS - PART 2
be
1. Consider the following employees data as
source employee_id
salary
employee_id, salary V_count=V_count+1
10, 1000 V_salary=IIF(V_count=1,NULL,V_prev_salary)
20, 2000 V_prev_salary=salary
30, 3000 O_prev_salary=V_salary
40, 5000
Q1. Design a mapping to load the cumulative Q3. Design a mapping to get the next row salary
sum of salaries of employees into target table? for the current row. If there is no next row for the
The target table data should look like as current row, then the next row salary should be
displayed as null.
employee_id, salary, cumulative_sum The output should look like as
10, 1000, 1000
20, 2000, 3000 employee_id, salary, next_row_salary
30, 3000, 6000 10, 1000, 2000
40, 5000, 11000 20, 2000, 3000
30, 3000, 5000
Solution: 40, 5000, Null
Step1: Use a sorter transformation and sort the If the filter condition is set to TRUE, then it
data using the sort key as department_no and passes all the rows without filtering any data. In
then pass the output to the expression this case, the filter transformation acts as
transformation. In the expression transformation, passive transformation.
the ports will be
4. Can we concatenate ports from more than
department_no one transformation into the filter transformation?
employee_name
V_curr_deptno=department_no No. The input ports for the filter must come from
V_employee_list = IIF(V_curr_deptno! = a single transformation.
V_prev_deptno,employee_name,V_employee_li
st||','||employee_name) 5. How to filter the null values and spaces?
V_prev_deptno=department_no
O_employee_list = V_employee_list Use the ISNULL and IS_SPACES functions
Example:
Step2: Now connect the expression IIF(ISNULL(commission),FALSE,TRUE)
transformation to a target table.
6. How session performance can be improved Full outer join: A full outer join keeps all
by using filter transformation? rows of data from both the master and detail
rows.
Keep the filter transformation as close as 5. What is joiner cache?
possible to the sources in the mapping. This
allows the unwanted data to be discarded and When the integration service processes a joiner
the integration service processes only the transformation, it reads the rows from master
required rows. If the source is relational source, source and builds the index and data cached.
use the source qualifier to filter the rows. Then the integration service reads the detail
source and performs the join. In case of sorted
INFORMATICA INTERVIEW QUESTIONS ON joiner, the integration service reads both sources
JOINER TRANSFORMATION (master and detail) concurrently and builds the
cache based on the master rows.
1. What is a joiner transformation?
6. How to improve the performance of joiner
A joiner transformation joins two heterogeneous transformation?
sources. You can also join the data from the Join sorted data whenever possible.
same source. The joiner transformation joins
sources with at least one matching column. The For an unsorted Joiner transformation,
joiner uses a condition that matches one or designate the source with fewer rows as the
more joins of columns between the two sources. master source.
For a sorted Joiner transformation,
2. How many joiner transformations are required designate the source with fewer duplicate key
to join n sources? values as the master source.
To join n sources n-1 joiner transformations are 7. Why joiner is a blocking transformation?
required.
When the integration service processes an
3. What are the limitations of joiner unsorted joiner transformation, it reads all
transformation? master rows before it reads the detail rows. To
You cannot use a joiner transformation ensure it reads all master rows before the detail
when input pipeline contains an update strategy rows, the integration service blocks all the
transformation. details source while it caches rows from the
You cannot use a joiner if you connect a master source. As it blocks the detail source, the
sequence generator transformation directly unsorted joiner is called a blocking
before the joiner. transformation.
A rank transformation is used to select top or A router is used to filter the rows in a mapping.
bottom rank of data. This means, it selects the Unlike filter transformation, you can specify one
largest or smallest numeric value in a port or or more conditions in a router transformation.
group. Rank transformation also selects the Router is an active transformation.
strings at the top or bottom of a session sort
order. Rank transformation is an active 2. How to improve the performance of a session
transformation. using router transformation?
The designer creates RANKINDEX port for each The router transformation has the following
rank transformation. The integration service types of groups:
uses the rank index port to store the ranking Input
position for each row in a group. Output
4. How do you specify the number of rows you
want to rank in a rank transformation? 4. How many types of output groups are there?
In the rank transformation properties, there is an There are two types of output groups:
option 'Number of Ranks' for specifying the User-defined group
number of rows you wants to rank. Default group
5. Where you specify the filter conditions in the
5. How to select either top or bottom ranking for router transformation?
a column?
You can creat the group filter conditions in the
In the rank transformation properties, there is an groups tab using the expression editor.
option 'Top/Bottom' for selecting the top or
bottom ranking for a column. 6. Can you connect ports of two output groups
from router transformation to a single target?
6. Can we specify ranking on more than one
port? No. You cannot connect more than one output
group to one target or a single input group
No. We can specify to rank the data based on transformation.
only one port. In the ports tab, you have to
check the R option for designating the port as a
rank port and this option can be checked only on
one port.
INFORMATICA INTERVIEW QUESTIONS ON 8. What is the number of cached values set to
SEQUENCE GENERATOR default for a sequence generator
TRANSFORMATION transformation?
1. What is a sequence generator
For non-reusable sequence generators, the
transformation?
number of cached values is set to zero.
For reusable sequence generators, the number
A Sequence generator transformation generates
of cached values is set to 1000.
numeric values. Sequence generator
transformation is a passive transformation.
9. How do you configure a sequence generator
transformation?
2. What is the use of a sequence generator
transformation?
The following properties need to be configured
for a sequence generator transformation:
A sequence generator is used to create unique
Start Value
primary key values, replace missing primary key
values or cycle through a sequential range of Increment By
numbers. End Value
Current Value
3. What are the ports in sequence generator
transformation? Cycle
Number of Cached Values
A sequence generator contains two output ports.
They are CURRVAL and NEXTVAL.
INFORMATICA INTERVIEW QUESTIONS ON
4. What is the maximum number of sequence SORTER TRANSFORMATION
that a sequence generator can generate?
1. What is a sorter transformation?
The maximum value is
Sorter transformation is used to sort the data.
9,223,372,036,854,775,807
You can sort the data either in ascending or
descending order according to a specified sort
5. When you connect both the NEXTVAL and
key.
CURRVAL ports to a target, what will be the
output values of these ports?
2. Why sorter is an active transformation?
The output values are
As sorter transformation can suppress the
NEXTVAL CURRVAL
duplicate records in the source, it is called an
1 2
active transformation.
2 3
3 4
3. How to improve the performance of a session
4 5
using sorter transformation?
5 6
Sort the data using sorter transformation before
6. What will be the output value, if you connect
passing in to aggregator or joiner transformation.
only CURRVAL to the target without connecting
As the data is sorted, the integration service
NEXTVAL?
uses the memory to do aggregate and join
operations and does not use cache files to
The integration service passes a constant value
process the data.
for each row.
3. What are the different tasks a source qualifier 2. How do you configure a SQL transformation?
can do? The following options are required to configure
SQL transformation:
Join two or more tables originating from
the same source (homogeneous sources) Mode: Specifies the mode in which SQL
database. transformation runs. SQL transformation
supports two modes. They are script mode and
Filter the rows. query mode.
Sort the data Database type: The type of database
Selecting distinct values from the source that SQL transformation connects to.
Create custom query Connection type: Pass database
Specify a pre-sql and post-sql connection to the SQL transformation at run time
or specify a connection object.
4. What is the default join in source qualifier 3. What are the different modes in which a SQL
transformation? transformation runs?
SQL transformation runs in two modes. They
The source qualifier transformation joins the are:
tables based on the primary key-foreign key Script mode: The SQL transformation
relationship. runs scripts that are externally located. You can
pass a script name to the transformation with
5. How to create a custom join in source qualifier each input row. The SQL transformation outputs
transformation? one row for each input row.
Query mode: The SQL transformation
When there is no primary key-foreign key executes a query that you define in a query
relationship between the tables, you can specify editor. You can pass parameters to the query to
a custom join using the 'user-defined join' option define dynamic queries. You can output multiple
in the properties tab of source qualifier. rows when the query has a SELECT statement.
6. How to join heterogeneous sources and flat 4. In which cases the SQL transformation
files? becomes a passive transformation and active
transformation?
Use joiner transformation to join heterogeneous If you run the SQL transformation in script mode,
sources and flat files then it becomes passive transformation. If you
run the SQL transformation in the query mode
7. How do you configure a source qualifier and the query has a SELECT statement, then it
transformation? becomes an active transformation.
SQL Query
User-Defined Join 5. When you configure an SQL transformation to
Source Filter run in script mode, what are the ports that the
designer adds to the SQL transformation?
Number of Sorted Ports
The designer adds the following ports to the 10. When you enable the NumRowsAffected
SQL transformation in script mode: output port in script mode, what will be the
ScriptName: This is an input port. output?
ScriptName receives the name of the script to In script mode, the NumRowsAffected port
execute the current row. always returns NULL.
ScriptResult: This is an output port.
ScriptResult returns PASSED if the script 11. How do you limit the number of rows
execution succeeds for the row. Otherwise it returned by the select statement?
returns FAILED. You can limit the number of rows by configuring
the Max Output Row Count property. To
ScriptError: This is an output port. configure unlimited output rows, set Max Output
ScriptError returns the errors that occur when a Row Count to zero.
script fails for a row.
6. What are the types of SQL queries you can INFORMATICA INTERVIEW QUESTIONS ON
specify in the SQL transformation when you use STORED PROCEDURE TRANSFORMATION
it in query mode. 1. What is a stored procedure?
Static SQL query: The query statement
does not change, but you can use query A stored procedure is a precompiled collection
parameters to change the data. The integration of database procedural statements. Stored
service prepares the query once and runs the procedures are stored and run within the
query for all input rows. database.
Dynamic SQL query: The query
statement can be changed. The integration 2. Give some examples where a stored
service prepares a query for each input row. procedure is used?
8. How do you find the number of rows inserted, 4. In which scenarios a connected stored
updated or deleted in a table? procedure transformation is used?
You can enable the NumRowsAffected output Run a stored procedure every time a
port to return the number of rows affected by the row passes through the mapping.
INSERT, UPDATE or DELETE query statements Pass parameters to the stored
in each input row. This NumRowsAffected option procedure and receive multiple output
works in query mode. parameters.
2. Design a mapping to convert column data into Step1: Use sorter transformation and sort the
row data without using the normalizer data using id port as the key. Then connect the
transformation. sorter transformation to the expression
The source data looks like transformation.
STEP2: Connect the Source Qualifier STEP2: Now connect all the three Source
Transformation to the Expression Qualifier transformations to the Union
Transformation. In the Expression Transformation. Then connect the Union
Transformation, create three variable ports and Transformation to the Sorter Transformation. In
one output port. Assign the expressions to the the sorter transformation sort the data based on
ports as shown below. Id port in ascending order.
Solution:
The products table contains the below data.
SQL QUERIES INTERVIEW QUESTIONS -
ORACLE PART 1 SELECT * FROM PRODUCTS;
As a database developer, writing SQL queries, PRODUCT_ID PRODUCT_NAME
PLSQL code is part of daily life. Having a good 100 Nokia
knowledge on SQL is really important. Here i am 200 IPhone
posting some practical examples on SQL 300 Samsung
queries.
The sales table contains the following data.
To solve these interview questions on SQL
queries you have to create the products, sales SELECT * FROM SALES;
tables in your oracle database. The "Create SALE_ID PRODUCT_ID YEAR QUANTITY
Table", "Insert" statements are provided below. PRICE
1 100 2010 25
CREATE TABLE PRODUCTS 5000
( 2 100 2011 16
PRODUCT_ID INTEGER, 5000
PRODUCT_NAME VARCHAR2(30) 3 100 2012 8
); 5000
CREATE TABLE SALES 4 200 2010 10
( 9000
SALE_ID INTEGER, 5 200 2011 15
PRODUCT_ID INTEGER, 9000
YEAR INTEGER, 6 200 2012 20
Quantity INTEGER, 9000
PRICE INTEGER 7 300 2010 20
); 7000
INSERT INTO PRODUCTS VALUES ( 100, 8 300 2011 18
'Nokia'); 7000
INSERT INTO PRODUCTS VALUES ( 200, 9 300 2012 20
'IPhone'); 7000
INSERT INTO PRODUCTS VALUES ( 300,
'Samsung'); Here Quantity is the number of products sold in
INSERT INTO PRODUCTS VALUES ( 400, each year. Price is the sale price of each
'LG'); product.
INSERT INTO SALES VALUES ( 1, 100,
2010, 25, 5000); I hope you have created the tables in your
INSERT INTO SALES VALUES ( 2, 100, oracle database. Now try to solve the below
2011, 16, 5000); SQL queries.
INSERT INTO SALES VALUES ( 3, 100,
2012, 8, 5000); 1. Write a SQL query to find the products which
INSERT INTO SALES VALUES ( 4, 200, have continuous increase in sales every year?
2010, 10, 9000);
INSERT INTO SALES VALUES ( 5, 200, Solution:
2011, 15, 9000);
INSERT INTO SALES VALUES ( 6, 200, Here “Iphone” is the only product whose sales
2012, 20, 9000); are increasing every year.
INSERT INTO SALES VALUES ( 7, 300,
2010, 20, 7000); STEP1: First we will get the previous year sales
INSERT INTO SALES VALUES ( 8, 300,
for each product. The SQL query to do this is
2011, 18, 7000);
INSERT INTO SALES VALUES ( 9, 300, SELECT P.PRODUCT_NAME,
2012, 20, 7000); S.YEAR,
COMMIT; S.QUANTITY,
LEAD(S.QUANTITY,1,0) OVER (
does not have sales at all?
PARTITION BY P.PRODUCT_ID
ORDER Solution:
BY S.YEAR DESC
) “LG” is the only product which does not have
QUAN_PREV_YEAR sales at all. This can be achieved in three ways.
FROM PRODUCTS P,
SALES S Method1: Using left outer join.
WHERE P.PRODUCT_ID = S.PRODUCT_ID;
SELECT P.PRODUCT_NAME
PRODUCT_NAME YEAR QUANTITY FROM PRODUCTS P
QUAN_PREV_YEAR LEFT OUTER JOIN
Nokia 2012 8 16 SALES S
Nokia 2011 16 25 ON (P.PRODUCT_ID =
Nokia 2010 25 0 S.PRODUCT_ID);
IPhone 2012 20 15 WHERE S.QUANTITY IS NULL
IPhone 2011 15 10
IPhone 2010 10 0 PRODUCT_NAME
Samsung 2012 20 18 LG
Samsung 2011 18 20
Samsung 2010 20 0 Method2: Using the NOT IN operator.
Here the lead analytic function will get the SELECT P.PRODUCT_NAME
quantity of a product in its previous year. FROM PRODUCTS P
WHERE P.PRODUCT_ID NOT IN
STEP2: We will find the difference between the (SELECT DISTINCT PRODUCT_ID
quantities of a product with its previous year’s FROM SALES);
quantity. If this difference is greater than or
equal to zero for all the rows, then the product is PRODUCT_NAME
a constantly increasing in sales. The final query LG
to get the required result is
Method3: Using the NOT EXISTS operator.
SELECT PRODUCT_NAME
FROM SELECT P.PRODUCT_NAME
( FROM PRODUCTS P
SELECT P.PRODUCT_NAME, WHERE NOT EXISTS
S.QUANTITY – (SELECT 1 FROM SALES S WHERE
LEAD(S.QUANTITY,1,0) OVER ( S.PRODUCT_ID = P.PRODUCT_ID);
The ratio of a product is calculated as the total PIVOT ( MAX(QUANTITY) AS QUAN FOR
sales price in a particular year divide by the total (YEAR) IN (2010,2011,2012));
sales price across all years. Oracle provides
RATIO_TO_REPORT analytical function for If you are not running oracle 11g database, then
finding the ratios. The SQL query is use the below query for transposing the row
data into column data.
SELECT P.PRODUCT_NAME,
S.YEAR, SELECT P.PRODUCT_NAME,
MAX(DECODE(S.YEAR,2010,
RATIO_TO_REPORT(S.QUANTITY*S.PRICE) S.QUANTITY)) QUAN_2010,
OVER(PARTITION BY MAX(DECODE(S.YEAR,2011,
P.PRODUCT_NAME ) SALES_RATIO S.QUANTITY)) QUAN_2011,
FROM PRODUCTS P, MAX(DECODE(S.YEAR,2012,
SALES S S.QUANTITY)) QUAN_2012
FROM PRODUCTS P, )
SALES S WHERE TO_CHAR(C_DATE,'DY') = 'FRI';
WHERE (P.PRODUCT_ID = S.PRODUCT_ID)
GROUP BY P.PRODUCT_NAME; 3. Write a query to duplicate each row based on
the value in the repeat column? The input table
5. Write a query to find the number of products data looks like as below
sold in each year?
Solution:
S
SELECT C_DATE, M
TO_CHAR(C_DATE,'DY') I
FROM L
( E
SELECT TO_DATE('01-JAN-2000','DD-
MON-YYYY')+LEVEL-1 C_DATE Solution:
FROM DUAL SELECT SUBSTR('SMILE',LEVEL,1) A
CONNECT BY LEVEL <= FROM DUAL
(SYSDATE - TO_DATE('01-JAN- CONNECT BY LEVEL <=LENGTH('SMILE');
2000','DD-MON-YYYY')+1)
5. Convert the string "SMILE" to Ascii values? Name, Friend_of_Firend
The output should look like as 83,77,73,76,69. sam, ram
Where 83 is the ascii value of S and so on. sam, jhon
The ASCII function will give ascii value for only
one character. If you pass a string to the ascii sam, vijaysam, anand
function, it will give the ascii value of first letter in
the string. Here i am providing two solutions to Solution:
get the ascii values of string.
); SELECT f1.name,
f2.friend_name as
friend_of_friend
FROM friends f1,
SQL QUERIES INTERVIEW QUESTIONS - friends f2
ORACLE PART 4 WHERE f1.name = 'sam'
AND f1.friend_name = f2.name
1. Consider the following friends table as the AND NOT EXISTS
source (SELECT 1 FROM friends f3
WHERE f3.name = f1.name
Name, Friend_Name AND f3.friend_name =
sam, ram f2.friend_name);
sam, vamsi
vamsi, ram 3. Write a query to get the top 5 products based
vamsi, jhon on the quantity sold without using the
ram, vijay row_number analytical function? The source
ram, anand data looks as