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



David,

In the specific case when a customer has multiple professions, which one
should be used? The first one found, the "most recent", or something
else? RPG CHAIN will just pick the first one it finds unless you are
using a keyed file; again the expectation is based on the key.

One of the biggest mental roadblocks to SQL acceptance in programmers is
the switch from "record at a time" to "set at a time" processing. In RPG
you are concerned just about this one record, and do that a bunch of
times. In SQL you try to find all the data at once and act on it.

Anytime I need to update data using SQL, I perform a select statement to
determine if I'm updating the correct rows, and which data will be used.
Almost certainly this would have caught the multiple profession
condition because multiple rows would be returned for a customer. Then
it's a matter of narrowing the profession to be used.


Loyd Goodbar
Business Systems
BorgWarner Shared Services
662-473-5713

-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of David FOXWELL
Sent: Friday, July 18, 2008 10:00 AM
To: Midrange Systems Technical Discussion
Subject: RE: Updating with the column from another file

Thanks, I was trying to do it with one request, like this.

update oldfile a
set a.profession = ( select profession from
custmast join custdos on
Custmast.cust = custdos.cust where custdos.dossier = a.dossier )
where exists ( select custdos.dossier from custdos where
custdos.dossier= a.dossier )

This worked if the customer had only one dossier.

But I prefer the good old RPG way :
CHAIN dossier custdos;
IF %FOUND;
CHAIN custdos.cust custmast;
IF %FOUND;
profession = custmast.profession;

ENDIF;
ENDIF;



As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.