Stored Procedure Transformation in Informatica
Stored Procedure Transformation in Informatica
Stored Procedure Transformation in Informatica
Transformation
Author: Chandrashekar.S.N
E-mail: chandrashekar.snc@wipro.com
Stored Procedure
Transformation
Contents:
1. Overview...............................................................................................3
1.1.Stored Procedure Transformation connection mode......................................................................3
1.2.Using a Stored Procedure in a Mapping........................................................................................3
8.References:.........................................................................................11
Stored Procedure
Transformation
1. Overview
Stored Procedure transformation (passive type) is used for populating and maintaining databases.
A stored procedure is a set of Structured Query Language (SQL) statements with an assigned name
that's stored in the database in compiled form so that it can be shared by a number of programs. The
use of stored procedures can be helpful in controlling access to data (end-users may enter or change
data but do not write procedures), preserving data integrity (information is entered in a consistent
manner), and improving productivity (statements in a stored procedure only need to be written one
time). You can run a stored procedure with the EXECUTE SQL statement in a database client tool, just
as you can run SQL statements. Unlike standard SQL, however, stored procedures allow user-defined
variables, conditional statements, and other powerful programming features.
Note: The stored procedure must exist in the source, target, or any database with a valid
connection to the Integration Service before creating a Stored Procedure transformation
1.1.
Stored procedures run in either connected or unconnected mode. The mode you use depends on what
the stored procedure does and how you plan to use it in a session
Connected. The flow of data through a mapping in connected mode also passes through the
Stored Procedure transformation. All data entering the transformation through the input ports
affects the stored procedure.
Note: Stored procedure should contain at least one input and one output parameter
Using a Stored Procedure in a Mapping
Steps to be followed:
If unconnected, either configure the stored procedure to run pre- or post-session, or configure it
to run from an expression in another transformation.
Since stored procedures can run before or after the session, you may need to specify when the
unconnected transformation should run. On the other hand, if the stored procedure is called
Stored Procedure
Transformation
from another transformation, you write the expression in another transformation that calls the
stored procedure.
IN. Defines the parameter something that must be passed to the stored procedure.
OUT. Defines the parameter as a returned value from the stored procedure.
INOUT. Defines the parameter as both input and output. Only Oracle supports this parameter
type.
Stored Procedure
Transformation
Use the Import Stored Procedure dialog box to configure the ports used by the stored
procedure.
Configure the transformation manually, creating the appropriate ports for any input or output
parameters.
Stored Procedure transformations are created as Normal type by default, which means that they run
during the mapping, not before or after the session.
Stored Procedure
Transformation
Required input parameters are specified as the input ports of the Stored Procedure transformation.
Output parameters appear as output ports in the transformation. A return value is also an output port,
and has the R value selected in the transformation Ports configuration. For a normal connected Stored
Procedure to appear in the functions list, it requires at least one input and one output port.
Output parameters and return values from the stored procedure are used as any other output port in a
transformation. You can map the value of these ports directly to another transformation or target.
From an expression. Called from an expression written in the Expression Editor within another
transformation in the mapping.
The sections below explain how you can run an unconnected Stored Procedure transformation.
Calling a Stored Procedure from an Expression
In an unconnected mapping, the Stored Procedure transformation does not connect to the pipeline.
Below figure shows a mapping with an Expression transformation that references the Stored Procedure
transformation:
Stored Procedure
Transformation
However, just like a connected mapping, you can apply the stored procedure to the flow of data through
the mapping. In fact, you have greater flexibility since you use an expression to call the stored
procedure, which means you can select the data that you pass to the stored procedure as an input
parameter.
Note: For more information on configuring stored procedure transformation please go through
informatica help.
Stored Procedure
Transformation
Below procedure was written in the database (Microsoft SQL Server 2005)
create procedure sp_test1 (@cd_val_id int,@cd_tbl_id int output,@cd_tbl_desc varchar(192) output)
as
select @cd_tbl_id=cd_tbl_id,@cd_tbl_desc=expl_txt from cd_val where cd_val_id=@cd_val_id
return 0
stored procedure takes cd_val_id as input and returns cd_tbl_id and cd_tbl_desc as the output values.
Input parameter cd_val_id is passed from informatica and return values is captured in output
parameters cd_tbl_id and cd_tbl_desc.
Stored Procedure
Transformation
Stored Procedure
Transformation
Above window shows the properties that can be set for a stored procedure transformation.
Stored procedure name: It is the name used by integration service to call stored procedure.
Connection information: Here you can give the connection string to connect to database. By default
it is set to $target variable .You can overwrite this in workflow manager.
Call text: Text used by integration service to called stored procedure when it is not of normal type.
Execution order: Order in which the stored procedure need to be called in case of multiple stored
procedures. Used in case stored procedure is a not of normal type.
Tracing level: It is used for debugging purpose.
10
Stored Procedure
Transformation
11
Stored Procedure
Transformation
6. Summary
In Summary, we can say that stored procedure transformation can be used for populating and
managing the database. It can be used similar to lookup transformation. Stored Procedure
Transformation can be used in connected or unconnected mode. It can be used to do calculations
which could otherwise make mapping complex.
7. Appendix
7.1 Comparison of Connected and Unconnected Stored Procedure Transformations
One cannot use a stored procedure without an input and an output port. You need to have at
least one input and one output parameter. If there is a stored procedure without an input and
output parameter then u can use it with by creating one dummy input and one dummy output
parameter.
Results sets from an output of a stored procedure cannot be handled in informatica. It can be
handled by using the query contained in a stored procedure in the Source Qualifier (if it is a
simple query).
The maximum length of an SQL query that can be used in Source Qualifier is approximately
32000 characters.
8.References:
Informatica Documentation
Informatica developer network
12
Stored Procedure
Transformation
---------------------------****************************************------------------------
13