Function order_insert
This function inserts a new record in the orders database
table.
Function
order_insert
(orders.4gl):01 FUNCTION order_insert()
02
03 WHENEVER ERROR CONTINUE
04 INSERT INTO orders (
05 store_num,
06 order_num,
07 order_date,
08 fac_code,
09 ship_instr,
10 promo
11 ) VALUES (
12 order_rec.store_num,
13 order_rec.order_num,
14 order_rec.order_date,
15 order_rec.fac_code,
16 order_rec.ship_instr,
17 order_rec.promo
18 )
19 WHENEVER ERROR STOP
20
21 IF (SQLCA.SQLCODE <> 0) THEN
22 CLEAR FORM
23 ERROR SQLERRMESSAGE
24 RETURN FALSE
25 END IF
27
28 MESSAGE "Order added"
29 RETURN TRUE
30
31 END FUNCTIONNote:
- Lines
03thru19implement theINSERTSQL statement to create a new row in theorderstable. - Lines
21thru25handle potential SQL errors, and display a message and returnFALSEif the insert was not successful. - Lines
28and29display a message and returnTRUEin case of success.