writing to a hash file that already has data

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
dsfan2004
Participant
Posts: 10
Joined: Tue Feb 17, 2004 5:03 pm

writing to a hash file that already has data

Post by dsfan2004 »

Hi everyone,

If I write data to a has file that already has data, is it going to delete existing data on the has file? or the new data will do an update or insert to the hash file, that is, if the key of the new data correspond to an entry on the hash file, then update, else insert the new data.

Your answers will be greated appreciated.
tonystark622
Premium Member
Premium Member
Posts: 483
Joined: Thu Jun 12, 2003 4:47 pm
Location: St. Louis, Missouri USA

Post by tonystark622 »

DataStage will not clear the hash file unless you have 'Clear before writing' checked (on the input tab of the hash file stage) or " 'Create File checked' and 'Delete file before create' checked in the Options dialog (click the Options button) "

If you write data to a hash file that has existing data, it will overwrite any records it finds with existing keys with the new data coming in. In effect "last record in wins". If the key doesn't exist, it will insert it into the hash file.

I hope this helps,
Tony
mhester
Participant
Posts: 622
Joined: Tue Mar 04, 2003 5:26 am
Location: Phoenix, AZ
Contact:

Post by mhester »

If you do not tell the stage to clear or create the file then existing data are preserved unless you are writing a row that already exists. All writes to a Hash are destructive meaning that if the record exists it will be replaced with the new row.

There are techniques (and have been explained via this forum) on how to essentially update hash files so try a search and see what you can find.

Regards,
Post Reply