Page 1 of 1

how to read selected rows using sequential file

Posted: Thu Jun 24, 2010 2:25 am
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

Posted: Thu Jun 24, 2010 2:43 am
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

Posted: Thu Jun 24, 2010 3:35 am
by Sreenivasulu
Put a constraint in the transformer. There is no way you can filter in the 'source' itself.

Regards
Sreeni

Posted: Thu Jun 24, 2010 3:36 am
by Sainath.Srinivasan
You can constraint in the source by applying a filter of

Code: Select all

grep '^10 ' yourFileName

Posted: Thu Jun 24, 2010 6:04 am
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:

Posted: Fri Jun 25, 2010 8:00 am
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.

Posted: Fri Jun 25, 2010 8:23 am
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.

Posted: Fri Jun 25, 2010 8:27 am
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.

Posted: Fri Jun 25, 2010 4:23 pm
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.