Problem solve Get help with specific problems with your technologies, process and projects.

SQL update a field in one file from a field in another file

You can easily update a field in one file with SQL by using a field in another file where unique field matching is possible.

You can easily update a field in one file with SQL by using a field in another file where unique field matching...

is possible. In the example, I want to update all the load dates in FILE1 to contain the same load date as found in FILE2 matching the two files by company and claim.

COALESCE covers the situation where one field may contain a NULL.

Note that the field to be updated must be compatible with the field updated from.

UPDATE FILE1 A SET A.LOADDT = (SELECT COALESCE(B.LOADDT, A.LOADDT) FROM FILE2 B WHERE A.COMP = B.COMP AND A.CLAIM = B.CLAIM)

==================================
MORE INFORMATION ON THIS TOPIC
==================================

The Best Web Links: tips, tutorials and more.

Visit the ITKnowledge Exchange and get answers to your developing questions fast.

Ask the Experts yourself: Our application development gurus are waiting to answer your programming questions.


Dig Deeper on RPG iSeries programming

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataCenter

Close