Function item_insert
This function inserts a new row into the items database table using
the values input in the current array record on the form.
Function
item_insert: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 FUNCTIONNote:
- Line
02the index of the current row in the array is passed to this function and stored in the variablecurr_pa. - Lines
05thru15The embedded SQLINSERTstatement uses the value oforder_numfrom the current order record displayed on the form, together with the values from the current row of thearr_itemsarray, to insert a new row in theitemstable.