Multiple recordtypes in a single flatfile

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
victorbos
Participant
Posts: 24
Joined: Tue Jul 15, 2003 2:05 am
Contact:

Multiple recordtypes in a single flatfile

Post by victorbos »

Hi all,

I have a sequentialfile as input that has two recordtypes.
The two recordtypes are of a completly different layout.
I have a table definition for both recordtypes. Can I use those to write the contents of the file to two database tables?

thanks in advance,

Victor
mkeevil
Participant
Posts: 59
Joined: Mon Jul 14, 2003 12:59 pm
Location: USA

Post by mkeevil »

Most times when I have a file with 2 or more differnt layouts, the file should have a record type indicator, something to tell you what kind of record it is. You can probably use this indicator in the Transform stage to direct the record though the correct layout and into the correct file.
victorbos
Participant
Posts: 24
Joined: Tue Jul 15, 2003 2:05 am
Contact:

Post by victorbos »

Yes, I do have a recordtype indicator.
The trouble is that when I split the file in a Transformer, I cannot use the sequentialfile-definition to read the record into columns, but am forced to use lots of substrings [,] to read the record.....

Victor
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Victorbos,

you can define your original file read in any column definition form as long as you can check your indicator field in a transform; I usually define the whole row as just one column if possible. Then, instead of having to parse out all of your columns, just write the data back to a file (I usually will use a pipe here to save I/O time) and read from that file using the correct column definitions. It is easy to do and also quite efficient.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Nice. 8)
-craig

"You can never have too many knives" -- Logan Nine Fingers
tonystark622
Premium Member
Premium Member
Posts: 483
Joined: Thu Jun 12, 2003 4:47 pm
Location: St. Louis, Missouri USA

Post by tonystark622 »

I believe with the newer versions of DataStage that you can use a RowSplitter stage to take the single column in and split it out into individual columns.
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Yes. RowSplitter does the trick.
fridge
Premium Member
Premium Member
Posts: 136
Joined: Sat Jan 10, 2004 8:51 am

Post by fridge »

You can also use the Complex File Stage with multiple output links - the selection page allows you to define the field as the rectype indicator and each output link can have different table defs on it

Its a more elegant, and understandable solution but I am not sure about performance vs reading from a seqstage - but these things are often a balance.

Ed
victorbos
Participant
Posts: 24
Joined: Tue Jul 15, 2003 2:05 am
Contact:

Post by victorbos »

Thanks for all the help!
The solution with a pipe runs smooth.

Victor
Post Reply