TOP INFORMATICA SCENARIO QUESTION (2024)

97. HOW CAN WE LOAD ‘X’ RECORDS (USER DEFINED RECORD NUMBERS) OUT OF ‘N’ RECORDS FROM SOURCE DYNAMICALLY,WITHOUT USING FILTER AND SEQUENCE GENERATOR TRANSFORMATION?

98.How to create Target Files Dynamically.

OR

(How to load all Employees data based upon Deptno in different target file through single Target Instance and Single Mapping.)

Ex:If Deptno=10 then create Target file as DEPT10.txt

If Deptno=20 then create Target file as DEPT20.txt

If Deptno=30 then create Target file as DEPT30.txt

http://informaticachamp.blogspot.in/2014/03/scenario-4-how-to-create-target-files.html

Dynamic Target Flat File Name Generation in Informatica

  • Create a new file for every session run
  • create a new file for each transaction.

Informatica provides a special port,”FileName” in the Target file definition. This port you have to add explicitly. See the below diagram for adding the “FileName” port.

Go to the Target Designer or Warehouse builder and edit the file definition. You have to click on the button indicated in red color circle to add the special port.

Now we will see some informatica mapping examples for creating the target file name dynamically and load the data.

1.Generate a new file for every session run.

Whenever the session runs you need to create a new file dynamically and load the source data into that file. To do this just follow the below steps:

STEP1:Connect the source qualifier to an expression transformation. In the expression transformation create an output port (call it as File_Name) and assign the expression as ‘EMP_’||to_char(sessstarttime, ‘YYYYMMDDHH24MISS’)||’.dat’

STPE2:Now connect the expression transformation to the target and connect eh File_Name port of expression transformation to the FileName port of the target file definition.

STEP3:Create a workflow and run the workflow.

Here I have used sessstarttime, as it is constant throughout the session run. If you have used sysdate, a new file will be created whenever a new transaction occurs in the session run.

The target file names created would look like EMP_20120101125040.dat.

2.Create a new file for every session run. The file name should contain suffix as numbers (EMP_n.dat)

In the above mapping scenario, the target flat file name contains the suffix as ‘timestamp.dat’. Here we have to create the suffix as a number. So, the file names should looks as EMP_1.dat, EMP_2.dat and so on. Follow the below steps:

STPE1:Go the mappings parameters and variables -> Create a new variable, $$COUNT_VAR and its data type should be Integer

STPE2:Connect the source Qualifier to the expression transformation. In the expression transformation create the following new ports and assign the expressions.

v_count (variable port) = v_count+1v_file_count (variable port) = IIF(v_count = 1, SETVARIABLE($$COUNT_VAR,$$COUNT_VAR+1),$$COUNT_VAR)o_file_name (output port) = 'EMP_'||v_file_count||'.dat'

STEP3:Now connect the expression transformation to the target and connect the o_file_name port of expression transformation to the FileName port of the target.

3.Createa newfile once a day.

You can create a new file only once in a day and can run the session multiple times in the day to load the data. You can either overwrite the file or append the new data.

This is similar to the first problem. Just change the expression in expression transformation to ‘EMP_’||to_char(sessstarttime, ‘YYYYMMDD’)||’.dat’. To avoid overwriting the file, use Append If Exists option in the session properties.

4.Create a flatfile based on the values in a port.

You can create a new file for each distinct values in a port. As an example consider the employees table as the source. I want to create a file for each department id and load the appropriate data into the files.

STEP1:Sort the data on department_id. You can either use the source qualifier or sorter transformation to sort the data.

STEP2:Connect to the expression transformation. In the expression transformation create the below ports and assign expressions.

v_curr_dept_id (variable port) = dept_idv_flag (variable port) = IIF(v_curr_dept_id=v_prev_dept_id,0,1)v_prev_dept_id (variable port) = dept_ido_flag (output port) = v_flago_file_name (output port) = dept_id||'.dat'

STEP4:Now connect the expression transformation to the transaction control transformation and specify the transaction control condition as

IIF(o_flag = 1, TC_COMMIT_BEFORE, TC_CONTINUE_TRANSACTION)

STEP5:Now connect to the target file definition.

Informatica 8.x or later versions provides a feature for generating the target files dynamically. This feature allows you to

99.Produce files as target with dynamic names

TOP INFORMATICA SCENARIO QUESTION (2024)
Top Articles
Latest Posts
Article information

Author: Rueben Jacobs

Last Updated:

Views: 5287

Rating: 4.7 / 5 (77 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Rueben Jacobs

Birthday: 1999-03-14

Address: 951 Caterina Walk, Schambergerside, CA 67667-0896

Phone: +6881806848632

Job: Internal Education Planner

Hobby: Candle making, Cabaret, Poi, Gambling, Rock climbing, Wood carving, Computer programming

Introduction: My name is Rueben Jacobs, I am a cooperative, beautiful, kind, comfortable, glamorous, open, magnificent person who loves writing and wants to share my knowledge and understanding with you.