SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Invalid identifier on Update statement
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

kylenedic
Starting Member

2 Posts

Posted - 07/20/2012 :  15:59:56  Show Profile  Reply with Quote
UPDATE XXINV.XXINV_ITEM_SNAP_EGS_E5A6 ISE
SET ISE.ORACLE_ON_HAND = (SELECT SUM (IVD.ON_HAND_QUANTITY)
FROM apps.XXRPT_INV_VALUATION_D535_V IVD
WHERE IVD.ITEM_NUMBER = IVD.ITEM_NUMBER
AND IVD.OWNING_ORG_CODE = IVD.OWNING_ORG_CODE )
WHERE ISE.ITEM_NUMBER = IVD.ITEM_NUMBER
AND ISE.ORGANIZATION_CODE = IVD.OWNING_ORG_CODE

I've been trying to update a table with info from another table and can't get it to work I keep getting an error of invalid identifier for IVD.OWNING_ORG_CODE at the end. Any suggestions?

Ive also tried this
UPDATE XXINV.XXINV_ITEM_SNAP_EGS_E5A6 ISE
SET ISE.ORACLE_ON_HAND = (SELECT SUM (IVD.ON_HAND_QUANTITY)
FROM apps.XXRPT_INV_VALUATION_D535_V IVD
WHERE IVD.ITEM_NUMBER = ISE.ITEM_NUMBER
AND IVD.OWNING_ORG_CODE = ISE.ORGANIZATION_CODE)
WHERE EXISTS ( SELECT SUM (IVD.ON_HAND_QUANTITY)
FROM apps.XXRPT_INV_VALUATION_D535_V IVD
WHERE IVD.ITEM_NUMBER = ISE.ITEM_NUMBER
AND IVD.OWNING_ORG_CODE = ISE.ORGANIZATION_CODE)

TG
Flowing Fount of Yak Knowledge

USA
5469 Posts

Posted - 07/20/2012 :  16:23:41  Show Profile  Reply with Quote
assuming you are using MS Sql Server 2005 or later try this:

update ise set
       ISE.ORACLE_ON_HAND = ca.on_hand_quantity_sum
from   XXINV.XXINV_ITEM_SNAP_EGS_E5A6 ISE
cross apply (
       select sum(dvd.on_hand_quantity) on_hand_quantity_sum
       from   apps.XXRPT_INV_VALUATION_D535_V IVD
       where  ivd.item_number = ise.item_number
       ) ca


Be One with the Optimizer
TG
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000