There are 5 different date columns in a table. My input will be account number. I go to select the row using account number in which i also need to select the date which is max of the 5 date columns for that account.
The maximum date which is fetched for that account will then be inserted/updated in another table.
I am storing those 5 dates in an array in COBOL and getting the max of them to move to another table.
But experts, can you please advise if there is any simpler or effective way of doing this? Thanks in advance.
Found this (untested) on the web - might be worth a try:
from (select datecolumn1 as dateValue
select datecolumn5) as MaxDateValue
where account_number = :acct-num;
Alternatively, you could use the LE function MAX in your COBOL program to select the max value of the 5 returned dates - e.g.
MOVE FUNCTION MAX(WSDATE1 WSDATE2 WSDATE3 WSDATE4 WSDATE5) TO WS-MAXDATE.