Sequential File Stage and file name variable

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
harborboy76
Premium Member
Premium Member
Posts: 13
Joined: Wed Apr 07, 2010 11:50 pm

Sequential File Stage and file name variable

Post by harborboy76 »

What's the best approach to parse out the sequential file name to be used
as a variable inside Transformer Stage ? For our project, file name is a
unique ID that will be used within jobs to populate our target table.

Am I correct in thinking that I may have to use Job Sequence to execute
linux command (Execute Command Stage) to parse out the file name and
pass in as a variable ? Or is there a simpler alternative to accomplish the
same thing.

Thanks!
N.K.
anbu
Premium Member
Premium Member
Posts: 596
Joined: Sat Feb 18, 2006 2:25 am
Location: india

Post by anbu »

Keep the filename as job parameter and use it in the transformer
You are the creator of your destiny - Swami Vivekananda
harborboy76
Premium Member
Premium Member
Posts: 13
Joined: Wed Apr 07, 2010 11:50 pm

Post by harborboy76 »

Would it mean that I have to know the file name ahead of time to be able
to pass it in at runtime ? I need to automate this since I may not always
know the file name ahead of time or want to look for file name to be
passed in as parameter manually. Sorry if I misunderstood your response.
N.K.
anbu
Premium Member
Premium Member
Posts: 596
Joined: Sat Feb 18, 2006 2:25 am
Location: india

Post by anbu »

Are you using sequential file stage and want to use this file name in transformer?
You are the creator of your destiny - Swami Vivekananda
harborboy76
Premium Member
Premium Member
Posts: 13
Joined: Wed Apr 07, 2010 11:50 pm

Post by harborboy76 »

That is correct -
N.K.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Not enough information for a cogent answer. How are you reading the files now - with a file pattern? Is that why you don't know the actual filename run to run? I'm assuming that, otherwise as others have noted you'd just use the job parameter that was passing it in.

There's an option in the Sequential File stage to add a column populated with the actual filename found. Don't recall exactly and can't check but should be easy enough to find. That would give you the filename in a new column as part of each record passing through the job.

And if it doesn't work as expected, check posts like this.
-craig

"You can never have too many knives" -- Logan Nine Fingers
harborboy76
Premium Member
Premium Member
Posts: 13
Joined: Wed Apr 07, 2010 11:50 pm

Post by harborboy76 »

It works!

Thank you very much for the pointer. Under Sequential File Stage, I
found File Name Column under Options. When I add that column name to
the output, I now have the file name (and the path). All I need to do now
is parsing out the file name.

This is too cool~! :)
N.K.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Code: Select all

Field(InLink.FileNameColumn, "/", Count(InLink.FileNameColumn, "/") + 1, 1)
Maybe you can mark this thread as Resolved?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
harborboy76
Premium Member
Premium Member
Posts: 13
Joined: Wed Apr 07, 2010 11:50 pm

Post by harborboy76 »

Oh, I will do that now. Thank you for the tip as well! :D
N.K.
Post Reply