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


On 7/19/2022 2:01 PM, Stephen Piland wrote:
Whoa. This works? That's awesome. Going to try it out in a few.

-----Original Message-----
From: RPG400-L<rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Hiebert, Chris
Sent: Tuesday, July 19, 2022 8:56 AM
To: RPG programming on IBM i<rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: RE: Update a table from EXTNAME-defined data structure using search argument

You are looking for "Set ROW"


EXEC SQL
UPDATE TABLE1
SET ROW = :TableDS
WHERE key = :TableDS.key;


If you have an identity column then override system value on update, and override user value on insert.

EXEC SQL
UPDATE TABLE1
Overriding System Value
SET ROW = :TableDS
WHERE key = :TableDS.key;


EXEC SQL
INSERT INTO TABLE1
Overriding User Value
Values ( :TableDS );


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 7:32 AM
To:rpg400-l@xxxxxxxxxxxxxxxxxx
Subject: Update a table from EXTNAME-defined data structure using search argument

Good morning folks,



I am updating a file. I have an externally defined data structure

defined with EXTNAME().



I can't find a specific reference anywhere, but is there a syntax to use

that data structure to update the row in the table, like so, maybe?



UPDATE TABLE1 SET TABLERECD = :TABLE-DS WHERE KEY1 = VALUE1 AND KEY2 =

VALUE2?



I have just seven fields to list out, and I'm doing that, but I just

wondered if there was a way to do the above (without having to input

with an update lock)?



Reason I'm asking is for the future, if I could set it up that way, it

would make it easier to add changes to other columns, and maybe other thins.



--Alan Cassidy


--
This is the RPG programming on IBM i (RPG400-L) mailing list To post a message email:RPG400-L@xxxxxxxxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit:https://lists.midrange.com/mailman/listinfo/rpg400-l
or email:RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives athttps://archive.midrange.com/rpg400-l.

Please contactsupport@xxxxxxxxxxxxxxxxxxxx for any subscription related questions.

Help support midrange.com by shopping at amazon.com with our affiliate link:https://amazon.midrange.com

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.