× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi, Mike!

Try:

UPDATE cltmas a
   SET a.kedagc = ( SELECT b.kedaga
                      FROM agtmas b
                     WHERE b.kedbca = a.kedagc )
 WHERE a.kedagc <> ' '
   AND EXISTS ( SELECT 1
                  FROM agtmas b
                 WHERE b.kedbca = a.kedagc )

Hope I spelled the column names correctly.  

This updates CLTMAS's kedagc column with AGTMAS's kedaga column where kedbca
= kedagc.  The EXISTS clause basically says only update the ones that exist
in the AGTMAS table so that you don't end up with nulls.

This will only work where kedbca = kedagc and one row is returned.  If more
than one row is returned from AGTMAS, you may have to do some tweaking
(i.e., min(), max(), where clause, etc.)

Good luck.

Roby

__________________________________
Robert A. Wayne, Jr.
Technical Solutions Specialist
nexgen Software Technologies, Inc.
mailto:wayne@xxxxxxxxxxxxxxxxxx

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of Mike Pantzopoulos - (H/O)
Sent: Monday, April 10, 2006 8:02 PM
To: rpg400-l@xxxxxxxxxxxx
Subject: SQL Update Question

I need to write a DB fix, and rather than use RPG I wanted to use SQL.
One file, CLTMAS needs to be updated with a value on another file
AGTMAS.

The following SQL Select works and shows me all the values that I need
to work with:

SELECT a.kedagc, b.kedaga, b.kedbca FROM cltmas a, agtmas b WHERE
a.kedagc <> ' ' and a.kedagc = b.kedbca    

a.kedagc                        b.kedaga
b.kedbca
======================================================
HCIAUST               04.0003315            HCIAUST  
SILVALAK              04.0020627            SILVALAK 
JOHNBERN              03.0000213            JOHNBERN 
SILVALAK              04.0020627            SILVALAK 
SILVALAK              04.0020627            SILVALAK 
INSSOLAU              04.0004115            INSSOLAU 
ARROWSM               03.0000552            ARROWSM  
ARROWSM               03.0000552            ARROWSM  
ARROWSM               03.0000552            ARROWSM  
ARROWSM               03.0000552            ARROWSM  
ARROWSM               03.0000552            ARROWSM  
JOHNBERN              03.0000213            JOHNBERN



 

I need to set a.kedagc = b.kedaga when there is a join on the two
records. I tried using this as the basis of an UPDATE statement, but
can't get it working. I think I need a sub-select but can't work it out.
In rough terms I need to SET a.kedagc= b.kedaga using the above WHERE
clause.

Anyone got a spare two minutes?

Thanks.

                     
Mike Pantzopoulos

EIG-Ansvar Limited
Tel  : 61 (3) 8630 3193
Fax:


****************************************************************************
*****************************
This email and any files transmitted with it are confidential and intended
solely for the use of the individual or entity to whom they are addressed.
If you are not the intended recipient, any use, disclosure or copying of
this message is unauthorised. If you have received this message in error,
please reply using the sender's email address. 

This footnote confirms that this email message has been scanned for computer
viruses. EIG-Ansvar Limited does not accept liability for any loss or
damage, whether caused by our own negligence or not, that results from a
computer virus or defect in the transmission of this email or any attached
file. 

EIG-Ansvar Limited - Australia (A.B.N. 21 007 216 506)
Email : insure@xxxxxxxxxxxxxxxx

Eig-Ansvar Limited - New Zealand
Email : insure@xxxxxxxxxxxxxxxx

****************************************************************************
*****************************

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.