Dynamic Informatica Target file generation (with looping on the files!!)

December 4, 2012

This was some good activity i was doing as part of some excercise on Informatica. All i had to do was to get a source and try loading the source into a target flat file. And here comes the real twist, i was required to load the data to a target and in a dynamic fashion, viz. to load the data to target file sat target_flat_file_1 at first run of session and so on till target_flat_file_5 as 5 different runs. Making 5 last backup of each loads.

After this we are also required to have the target load in a looping format, where after file5 the target has to load back from File1 and this way we have a last 5 target loads preserved. How to do this??

So here is how i made it:

Have your mapping designed with all that you require for your load run, and this is where we have a thing to work for us. In the Target creation of the Flat File we need to add one extra port ‘File_Name’ by clicking on the top-right end as is shown in below image – “Add FileName”.

Dynamic_target_img1

Then added he target to our mapping. Also we have one more task pending to decide on what way the name should be given, this can be achieved by an expression for the File Name port. Before that let me define a Mapping Variable as is below. (Make sure we have the Aggregator type as ‘COUNT’)

Dynamic_target_img3Then as we have our File_Name port to have an expression as is shown below, with a Variable Post to have any value between 1 to 5 as a normal Counter logic.

Dynamic_target_img2The Variable then is used in the FileName port as below and the output port from expression connected to the FileName port of the target as we had defined earlier.

Dynamic_target_img4Thereby we have things ready. Just define your session and run the mapping which shall load the target to the File named as per our expression.

NOTE: In doing this i had also to give some dummy file name in the Target file name in the session, say ‘Dummy_File.txt. And so every time i run the session it loads data to the File named as per FileName port and also there is a dummy file created with no data. Any one please let me know if i can have no target file defined at the session level?

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: