calculation for new record based on multiple existingrecords

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
harithay
Participant
Posts: 106
Joined: Tue Dec 14, 2004 10:51 pm

calculation for new record based on multiple existingrecords

Post by harithay »

Hi all,

i have to calculate change_ in_ TNA ( field) for new incoming records based on same records that alredy exist in sql server database.

the key columns to calculate 'change_in_tna' are fund_name, fund_no

fund_name, fund_no are not key columns in sql server database.

but there exist more than one record(with fund_name, cik) in database, and there may be moe than record in source.


if i take existing database into hashed filebased on key columns fund_name, cik. i get only one record with same fund_name , fund_no.


inorder to take other records(same fund_name, fund_no) into hashed file
i don't have any other key column

but i need to compare all incoming records with already existing records with same fund_name , fund_no


i know Hashed file stage does not work in this case , is there any other stage that will work for this scenario.


Thanks in Advance
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

You can reference the SQL server table itself.
vmcburney
Participant
Posts: 3593
Joined: Thu Jan 23, 2003 5:25 pm
Location: Australia, Melbourne
Contact:

Post by vmcburney »

You might be able to modify multiple records on the target table for each input record by writing a custom update SQL where you set the target field to a aggregation of the input field and the target field. Eg. UPDATE MYTABLE SET FIELDA = FIELDA + :1 WHERE FIELDB = :2
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You need joining (perhaps self-joining), grouping and possibly set functions when extracting from SQL Server.
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