7.13.2 COMMIT Example
Request that the user input details of an order and then write the order header and all associated lines to the database before issuing a commit operation:
GROUP_BY NAME(#ORDERHEAD) FIELDS(#ORDNUM #CUSTNUM #DATEDUE)
DEF_LIST NAME(#ORDERLINE) FIELDS(#ORDLIN #PRODUCT #QUANTITY #PRICE)
SET_MODE TO(*ADD)
INZ_LIST NAMED(#ORDERLINE) NUM_ENTRYS(20)
REQUEST FIELDS(#ORDERHEAD) BROWSELIST(#ORDERLINE)
INSERT FIELDS(#ORDERHEAD) TO_FILE(ORDHDR)
SELECTLIST NAMED(#ORDERLINE) GET_ENTRYS(*NOTNULL)
INSERT FIELDS(#ORDERLINE) TO_FILE(ORDLIN)
ENDSELECT
COMMIT
If the function were to fail when writing the 4th order line (say), then an automatic rollback would be issued. This would cause the order header and any order lines already created to be rolled back from the file.