Scenario:
How to generate target file names (like YYYYMMDDHH24:MISS.csv) dynamically from the mapping?
Solution:
In order to generate the target file names from the mapping, we should
make use of the special "FileName" port in the target file. You can't
create this special port from the usual New port button. There is a
special button with label "F" on it to the right most corner of the
target flat file when viewed in "Target Designer".
Below two screen-shots tell you how to create the special port in your target file.
Once this is done, the job is done. When you want to create the file
name with a timestamp attached to it, just use a port from an Expression
transformation before the target to pass a value of Output Port with
expression $$FILE_NAMEto_char(sessstarttime, 'YYYYMMDDHH24:MISS')'.csv'.
Please note that $$FILE_NAME is a parameter to the mapping and I've used sessstarttime because it will be constant through out the session run.
If you use sysdate, it will change if you have 100s of millions of records and if the session may run for an hour, each second a new file will get created.
Please note that a new file gets created with the current value of the port when the port value which maps to the FileName changes.
Comments
Post a Comment