Tutorial Chapter 11: Master/Detail / The Orders Program orders.4gl |
This function inserts a new row into the items database table using the values input in the current array record on the form.
01 FUNCTION item_insert(curr_pa) 02 DEFINE curr_pa SMALLINT 03 04 WHENEVER ERROR CONTINUE 05 INSERT INTO items ( 06 order_num, 07 stock_num, 08 quantity, 09 price 10 ) VALUES ( 11 order_rec.order_num, 12 arr_items[curr_pa].stock_num, 13 arr_items[curr_pa].quantity, 14 arr_items[curr_pa].price 15 ) 16 WHENEVER ERROR STOP 17 18 IF (SQLCA.SQLCODE == 0) THEN 19 MESSAGE msg08 20 ELSE 21 ERROR SQLERRMESSAGE 22 END IF 23 24 END FUNCTION