Thursday, March 14, 2013

How to Create User Defined Function (UDF) in Informatica

User defined functions are used to create complex functions by using the existing built-in functions provided by the informatica etl tool. This complex user defined function can be reused in multiple mappings. There are two types of user defined functions. They are:

  • Public UDF: Public UDFs can be used by all the users in the repository. Public UDFs can be used in transformations, Workflows, Link conditions and in Command task.
  • Private UDF: Private UDF can only be used inside a public UDF.
Creating User Defined Function:

Follow the below steps to create a
  • Login to the Mapping Designer and open any folder. Select the User-Defined Functions sub folder.
  • Go to toolbar, click on tools->User defined function->new. This opens a new window for creating the UDF. 
  • Now enter the UDF name in the Name field. Select the UDF type as public or private. Add the required number of arguments(Name, datatype, prcesision and scale).
  • Click on the Launch Editor button. This opens an expression editor window. Here define the functionality of the UDF by using the existing built-in functions, User defined function and Arguments.
  • Click on Ok and save the UDF.
The following image shows an example of creating a new UDF:

Managing User Defined Functions:

Once you created a UDF, you can see the properites, edit and delete the UDF. Right click on the UDF name for managing. The follwing image shows the options avialable for managing the UDF.

Important points:
  • Public UDFs cannot be changed to private UDFs. Where as private UDFs can be changed to Public UDFs.
  • You can call a user defined function by using :UDF prefix before the function name. Ex: :UDF.RemoveSpaces(Portname).
  • You cannot nest the a UDF within the same UDF.

No comments:

Post a Comment