how to read selected rows using sequential file

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
harikumar
Participant
Posts: 33
Joined: Wed Apr 21, 2010 9:19 pm
Location: banglore

how to read selected rows using sequential file

Post by harikumar »

i have data like

table
empno ename
10 sri
20 rama
10 hari
20 krishna


i want to read only empno 10 by using sequential file
devesh_ssingh
Participant
Posts: 148
Joined: Thu Apr 10, 2008 12:47 am

Post by devesh_ssingh »

do you required to build such a job ...?
in such case ....
just put constraint whatever you need to read
or from source file you want to read only those records?

user command
grep 10 filename

hope it will solve your problem
Sreenivasulu
Premium Member
Premium Member
Posts: 892
Joined: Thu Oct 16, 2003 5:18 am

Post by Sreenivasulu »

Put a constraint in the transformer. There is no way you can filter in the 'source' itself.

Regards
Sreeni
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

You can constraint in the source by applying a filter of

Code: Select all

grep '^10 ' yourFileName
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

More obvious and 'DataStage like' to simply constrain things after the file is read to only pass rows where the value in that column is 10. Something has to 'read' the entire file (being sequential media and all) so why not your job? Then (as a general comment) you don't have to worry about what to put in the Filter that will uniquely identify the proper rows, or if someone later will notice or even understand it, blah blah blah. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
Bongo51
Participant
Posts: 25
Joined: Fri Jun 25, 2010 7:41 am

Post by Bongo51 »

Hello, if I am reading this right, you desire to read in only one column out of four from the input sequential file.
Please try this and see if this is useful:
1. Import table definition.
2. Import into sequential file stage only the column you require as you have the option of excluding columns from the full table definition.
Hope this is understandable and useful.
vivekgadwal
Premium Member
Premium Member
Posts: 457
Joined: Tue Sep 25, 2007 4:05 pm

Post by vivekgadwal »

Bongo51 wrote:Hello, if I am reading this right, you desire to read in only one column out of four from the input sequential file.
Please try this and see if this is useful:
1. Import table definition.
2. Import into sequential file stage only the column you require as you have the option of excluding columns from the full table definition.
Hope this is understandable and useful.
This is not what the OP wants. I agree with Sainath's solution of having a filter command within the Sequential file stage. This should meet your requirements.
Vivek Gadwal

Experience is what you get when you didn't get what you wanted
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Not only not really what was wanted but wouldn't actually work either. While you can drop/exlcude columns downstream from the reader, unlike a relational source you cannot pick and choose your columns.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

But you CAN pick and choose your rows using a Filter command such as grep.

Actually, you *could* pick and choose columns as well by shifting to an External Source stage and using something like awk or sed.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply