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



I'm not a huge fan of converting "all" access to sql views.
It overly complicates some of the coding, and doesn't really help anything when you have to account for historic coding practices anyway.

We have a change management system that takes care of recompiling dependent objects.

So what does "UPDATE SET ROW" really give you?
It allows you to have one less part of the program you have to deal with when updating a database.

Yes, you have to add logic to validate and load your new fields.
But at least you don't have to remember to add one more column to that one update statement.


Reading from one view to load another table is real easy when the fields are named the same.
All you would need is two qualified data structures and EVAL-CORR.


Dcl-ds ds1 extname('TABLEFOROUTPUT') QUALIFIED;
Dcl-ds ds2 extname('TABLEFORINPUT) QUALIFIED;

// Clear DS1 to set default values for fields based on data type.
Clear DS1;
// map corresponding fields from the input table/view format, to the output format.
EVAL-CORR DS1 = DS2;
// set values for any DS1 unique fields.

// update the record.
EXEC SQL UPDATE TABLEFOROUTPUT
OVERRIDING SYSTEM VALUE
SET ROW = :DS1
WHERE KEY = :DS1.KEY;





Chris Hiebert
Senior Programmer/Analyst
Disclaimer: Any views or opinions presented are solely those of the author and do not necessarily represent those of the company.

From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Alan Cassidy
Sent: Tuesday, July 19, 2022 1:31 PM
To: rpg400-l@xxxxxxxxxxxxxxxxxx
Subject: Re: Update a table from EXTNAME-defined data structure using search argument

I learned something new today with that SET ROW! Thanks Chris! I ended up running the UPDATE with the SET listing each column separately. Safer that way. Although I did create an SQL View object creat
External (cfuture@xxxxxxxxxxx<mailto:cfuture@xxxxxxxxxxx>)

Report This Email<https://protection.inkyphishfence.com/report?id=d2luY29mb29kcy9jaHJpcy5oaWViZXJ0QHdpbmNvZm9vZHMuY29tLzUzMDRjZmQ5MDFiYWU5ZDdjZmFiZjIwYzcwMDM3MzYyLzE2NTgyNTkxMDMuNTk=#key=2116209a6958951359b6063ef5f83cab>


I learned something new today with that SET ROW! Thanks Chris!



I ended up running the UPDATE with the SET listing each column

separately. Safer that way.



Although I did create an SQL View object created for another program

where I fetch into a data structure that is defined with _EXTNAME

(viewname)_. Actually I'm using columns from that View to update one of

the physical files. So I think using the data structure may have given

me trouble..



UPDATE filename SET col1 = :value1, col2 = :value2, .... WHERE key1 =

:kval1 and key2 = :kval2.



--Alan



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.