Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread Getting too many records
Wed, Mar 25 2009 3:06 PMPermanent Link

Allan Brocklehurst
hello;
the following code gives me n times  n records where I really only want to update the existing "n" records
I have 3 and after this code I get 9 records.  Any Suggestions on what I can do in SQL to do this. To get the job done I wrote code to loop thru the
target table looking for existing DHA and Items

UPDATE SAP_XREF_COMP
SET
[SAP_ZID] = [SAPITEMMASTER_20090114].[SAPMASTER IDENTIFIER],
[SAP_ITEMNO] = [SAPITEMMASTER_20090114].[ITEMNO],
[SAP_DHA] = [SAPITEMMASTER_20090114].[PLANT]
FROM SAP_XREF_COMP
JOIN "SAPITEMMASTER_20090114" ON [SAPITEMMASTER_20090114].[ITEMNO] = [SAP_XREF_COMP].[XREF_ITEMNO]
AND SAPITEMMASTER_20090114].[PLANT] = [SAP_XREF_COMP].[XREF_DHA]

TIA
Allan
Thu, Mar 26 2009 5:43 AMPermanent Link

"John Hay"
Allan

>  the following code gives me n times  n records where I really only want
to update the existing "n" records
> I have 3 and after this code I get 9 records.  Any Suggestions on what I
can do in SQL to do this. To get the job done I wrote code to loop thru the
> target table looking for existing DHA and Items
>
> UPDATE SAP_XREF_COMP
> SET
> [SAP_ZID] = [SAPITEMMASTER_20090114].[SAPMASTER IDENTIFIER],
> [SAP_ITEMNO] = [SAPITEMMASTER_20090114].[ITEMNO],
> [SAP_DHA] = [SAPITEMMASTER_20090114].[PLANT]
> FROM SAP_XREF_COMP
> JOIN "SAPITEMMASTER_20090114" ON [SAPITEMMASTER_20090114].[ITEMNO] =
[SAP_XREF_COMP].[XREF_ITEMNO]
> AND SAPITEMMASTER_20090114].[PLANT] = [SAP_XREF_COMP].[XREF_DHA]

Are you sure ?  This code should not insert any records, only update
existing ones.  You also only need to update ZID as the other 2 fields must
already be set correctly.

John

Thu, Mar 26 2009 8:37 AMPermanent Link

Allan Brocklehurst

John;
I should have gone back to the SQL where I created the table BEFORE I wrote my plea in this ng.
I created more records than I should of there.
The Updates work as expected.  
Sorry for any problems. By the time I fixed this was at the end of 12 hours here and I was tired and a bit pissed

Allan

"John Hay" wrote:

Allan

>  the following code gives me n times  n records where I really only want
to update the existing "n" records
> I have 3 and after this code I get 9 records.  Any Suggestions on what I
can do in SQL to do this. To get the job done I wrote code to loop thru the
> target table looking for existing DHA and Items
>
> UPDATE SAP_XREF_COMP
> SET
> [SAP_ZID] = [SAPITEMMASTER_20090114].[SAPMASTER IDENTIFIER],
> [SAP_ITEMNO] = [SAPITEMMASTER_20090114].[ITEMNO],
> [SAP_DHA] = [SAPITEMMASTER_20090114].[PLANT]
> FROM SAP_XREF_COMP
> JOIN "SAPITEMMASTER_20090114" ON [SAPITEMMASTER_20090114].[ITEMNO] =
[SAP_XREF_COMP].[XREF_ITEMNO]
> AND SAPITEMMASTER_20090114].[PLANT] = [SAP_XREF_COMP].[XREF_DHA]

Are you sure ?  This code should not insert any records, only update
existing ones.  You also only need to update ZID as the other 2 fields must
already be set correctly.

John
Thu, Mar 26 2009 11:17 AMPermanent Link

"John Hay"
Allan

> Sorry for any problems. By the time I fixed this was at the end of 12
hours here and I was tired and a bit pissed

Not pissed in the British sense I hope Smile

John

Thu, Mar 26 2009 12:09 PMPermanent Link

Allan Brocklehurst
John;
Pissed in he British sense is the same as in the Canadian sense Smile

I really,really wanted to get pissed after yesterdays work was done.  But, today is much of the same (i'm on a tight timeline). So, I have to settle
for just being pissed off

Allan

"John Hay" wrote:

Allan

> Sorry for any problems. By the time I fixed this was at the end of 12
hours here and I was tired and a bit pissed

Not pissed in the British sense I hope Smile

John
Image