Tutorial Chapter 13: Master/Detail using Multiple Dialogs / The Orders Program orders.4gl |
This function validates that the values in the order_rec program record are correct, and then executes an SQL statement to update the row in the orders database table.
01 FUNCTION order_update(d) 02 DEFINE d ui.Dialog 03 04 IF NOT order_validate(d) THEN RETURN FALSE END IF 05 06 WHENEVER ERROR CONTINUE 07 UPDATE orders SET 08 store_num = order_rec.store_num, 09 order_date = order_rec.order_date, 10 fac_code = order_rec.fac_code, 11 ship_instr = order_rec.ship_instr, 12 promo = order_rec.promo 13 WHERE orders.order_num = order_rec.order_num 14 WHENEVER ERROR STOP 15 16 IF SQLCA.SQLCODE <> 0 THEN 17 CALL __mbox_ok(title1,SQLERRMESSAGE,"stop") 18 RETURN FALSE 19 END IF 20 21 CALL d.setFieldTouched("orders.*", FALSE) 22 MESSAGE SFMT(msg17, order_rec.order_num) 23 24 RETURN TRUE 25 26 END FUNCTION