Problem while inserting and updating a same SQL server table

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
Hope
Participant
Posts: 97
Joined: Sun May 13, 2007 2:51 pm
Contact:

Problem while inserting and updating a same SQL server table

Post by Hope »

My requirement is to insert 3306 records from a FILE A in to table A and update these records in Table A from another FILE B which has 2642 on key match.
These two files have 2642 common records.I am inserting 3306 records in to SQL server Table A. Later I am updating Table A with 2642 records.When I update the table the result I am getting is 2605 records when I am supposed to get 2642.I thought may be there were no keys matching so I was not getting 2642 records. To make sure if there were keys match ,I joined these two flat files on keys using a lookup stage and wrote the data in to flat file and I got 2642 record.another way I approached was I inserted 3306 records in to Table A and 2642 in to Table B and updated Table A from Table B using a SQL query I still got 2605 records. but If I do an inner join for these two tables I on keys I am getting 2642 records.I am unable to understand where I am going wrong. Please help.
csri
Participant
Posts: 99
Joined: Wed Jul 11, 2007 8:02 am

Re: Problem while inserting and updating a same SQL server t

Post by csri »

Hope wrote:My requirement is to insert 3306 records from a FILE A in to table A and update these records in Table A from another FILE B which has 2642 on key match.
These two files have 2642 common records.I am inserting 3306 records in to SQL server Table A. Later I am updating Table A with 2642 records.When I update the table the result I am getting is 2605 records when I am supposed to get 2642.I thought may be there were no keys matching so I was not getting 2642 records. To make sure if there were keys match ,I joined these two flat files on keys using a lookup stage and wrote the data in to flat file and I got 2642 record.another way I approached was I inserted 3306 records in to Table A and 2642 in to Table B and updated Table A from Table B using a SQL query I still got 2605 records. but If I do an inner join for these two tables I on keys I am getting 2642 records.I am unable to understand where I am going wrong. Please help.
Check if you have multiple records with the same key in your files A or B.
csri
Participant
Posts: 99
Joined: Wed Jul 11, 2007 8:02 am

Re: Problem while inserting and updating a same SQL server t

Post by csri »

Hope wrote:My requirement is to insert 3306 records from a FILE A in to table A and update these records in Table A from another FILE B which has 2642 on key match.
These two files have 2642 common records.I am inserting 3306 records in to SQL server Table A. Later I am updating Table A with 2642 records.When I update the table the result I am getting is 2605 records when I am supposed to get 2642.I thought may be there were no keys matching so I was not getting 2642 records. To make sure if there were keys match ,I joined these two flat files on keys using a lookup stage and wrote the data in to flat file and I got 2642 record.another way I approached was I inserted 3306 records in to Table A and 2642 in to Table B and updated Table A from Table B using a SQL query I still got 2605 records. but If I do an inner join for these two tables I on keys I am getting 2642 records.I am unable to understand where I am going wrong. Please help.
Check if you have multiple records with the same key in your files A or B.
Hope
Participant
Posts: 97
Joined: Sun May 13, 2007 2:51 pm
Contact:

Post by Hope »

yes I have multiple records.The datastage Directors log shows 2664 records are update but when I run a query I get only 2605. The same thing happens on the SQL server manager studio too if I run an update query it shows 2664 records updated when I run a query I get 2605 records.
csri
Participant
Posts: 99
Joined: Wed Jul 11, 2007 8:02 am

Post by csri »

It is possible. Example if you have one records with a key in file A and two records in file B with the same key then when you update with file B records datastage will show it as two records updated. Actually, only one record is updated twice if you look into the database. Hope it helps.
Hope
Participant
Posts: 97
Joined: Sun May 13, 2007 2:51 pm
Contact:

Post by Hope »

Thank you for the explanation.
Post Reply