Hi Peter
try the following
(COMPLETELY UNTESTED)
UPDATE ITEMBL A SET A.ITCLS =
(SELECT ITCLS FROM ITMRVA B
WHERE A.ITNBR = B.ITNBR AND B.STID = 'J2P' AND A.ITCLS <> B.ITCLS AND
A.HOUSE = 'JTG')
WHERE EXISTS
(SELECT * FROM ITMRVA B
WHERE A.ITNBR = B.ITNBR AND B.STID = 'J2P' AND A.ITCLS <> B.ITCLS AND
A.HOUSE = 'JTG')
Alan Shore
Programmer/Analyst, Direct Response
E:AShore@xxxxxxxx
P:(631) 200-5019
C:(631) 880-8640
"If you're going through Hell, keep going" - Winston Churchill
Peter_Vidal@pall.
com
Sent by: To
midrange-l-bounce midrange-l@xxxxxxxxxxxx
s@xxxxxxxxxxxx cc
Subject
05/05/2010 03:13 SQL UPDATE: Update a field with a
PM field from another file
Please respond to
Midrange Systems
Technical
Discussion
<midrange-l@midra
nge.com>
Hi list!
This is "my complication" on this simple SQL:
=======================================================
FILE:ITEMBL
FIELDS:
ITNBR - ITEM NUMBER (KEY FIELD)
HOUSE - WAREHOUSE (KEY FIELD)
ITCLS - ITEM CLASS
FILE:ITMRVA
FIELDS:
ITNBR - ITEM NUMBER (KEY FIELD)
STID - SITE ID
ITCLS - ITEM CLASS
Goal: Update ITCLS in ITEMBL with ITCLS in ITMRVA only if:
a) STID = 'J2P'
b) HOUSE = 'JTG'
c) ITEMBL.ITCLS <> ITMRVA.ITCLS
=======================================================
This is the SQL I am doing:
UPDATE ITEMBL A SET A.ITCLS =
(SELECT ITCLS FROM ITMRVA B
WHERE A.ITNBR = B.ITNBR AND B.STID = 'J2P' AND A.ITCLS <> B.ITCLS)
WHERE A.ITNBR = B.ITNBR AND A.HOUSE = 'JTG'
?
The error I am having is: COLUMN QUALIFIER OR TABLE B UNDEFINED. If I
remove the "B" qualifier from the last B.ITNBR in the SQL, then I have
this error instead: NULL VALUES NOT ALLOWED IN COLUMN OR VARIABLE ITCLS.
I can't see what I am doing wrong ... HELP! Thanks in advance!
PETER VIDAL
PALL CORPORATION / SR SYSTEM ANALYST @ WH APPLICATION DEVELOPMENT GROUP
10540 RIDGE RD., SUITE 203, NEW PORT RICHEY, FL 34654-5111
' 727-815-3104 Ä 7 727-815-3120 Ä þ WWW.PALL.COM
?Imagination is more important than knowledge...?
Albert Einstein (1879 - 1955)
--------------------------------------------------------------------------------
Attention:
This communication may contain information that is confidential,
privileged and/or exempt from disclosure under applicable law.
If you are not the intended recipient, please notify the sender
immediately and delete the original, all attachments, and all
copies of this communication.
--------------------------------------------------------------------------------
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at
http://archive.midrange.com/midrange-l.
As an Amazon Associate we earn from qualifying purchases.