× 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.


  • Subject: Re: Select & Update
  • From: Rob Berendt <rob@xxxxxxxxx>
  • Date: Thu, 29 Oct 1998 13:35:20 -0500

You did not qualify whether or not you are trying to update existing 
records, or insert new records.  You have no WHERE clause.  Therefore 
my first example is assuming that you are trying to insert new records:
INSERT INTO TABLEA (A, B)
    (SELECT C,D FROM TABLEB)

If you are trying to update existing records I think that what you want 
will require V4R3 of the operating system.  With that version they finally 
allowed you to update the values in one file with the values from another.  
Let's pretend that your tables have two additional fields:  TABLEA.KEYA, 
TABLEB.KEYB.  The statement will look like the following:
UPDATE TABLEA
   SET (A, B) =
        (SELECT C, D from TABLEB
            WHERE tablea.keya = keyb)






prakashsubramani@hotmail.com on 10/29/98 12:06:18 PM
Please respond to MIDRANGE-L@midrange.com@Internet
To:     MIDRANGE-L@midrange.com@Internet
cc:      

Subject:        Select & Update



Hi,

I have a situation wherein I do'nt know how to do that. The thing is , I 
have 2 tables Table A & Table B. 

Table A (in library A)                                       Table B(in 
library B)
----------                                                             
-----------
                                                                      
 Field A                                                           Field 
C

 Field B                                                           Field 
D

 Field E                                                           Field 
E

 Field F

 Now I want to select all fields of table A and update field A with 
Field C and Field B with Field D. When I try to do this via Interacive 
SQL , I get an error message saying that an Update to clause cannot be 
used with a Select statement. I tried SQLRPG through cursors but the 
result was the same. I will be happy if any one may be able to throw 
some light on how to do this. I use V4R1. 


Thanks.

Prakash.
















______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com
+---
| This is the Midrange System Mailing List!
| To submit a new message, send your mail to MIDRANGE-L@midrange.com.
| To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com.
| To unsubscribe from this list send email to MIDRANGE-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---


+---
| This is the Midrange System Mailing List!
| To submit a new message, send your mail to MIDRANGE-L@midrange.com.
| To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com.
| To unsubscribe from this list send email to MIDRANGE-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---


As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.