Function order_new

This function inserts a new row in the database table orders, using the values from the order_rec program record.

Function order_new (orders.4gl)
01 FUNCTION order_new()
02   SELECT MAX(order_num)+1 INTO order_rec.order_num 
03     FROM orders 
04   IF order_rec.order_num IS NULL
05    OR order_rec.order_num == 0 THEN
06     LET order_rec.order_num = 1
07   END IF
08  LET order_total = 0
09   -- We keep the same store...
10   LET order_rec.order_date = TODAY
11   LET order_rec.fac_code = "ASC"
12   LET order_rec.ship_instr = "FEDEX"
13   LET order_rec.promo = "N"
14
15   WHENEVER ERROR CONTINUE
16   INSERT INTO orders (
17      store_num,
18      order_num,
19      order_date,
20      fac_code,
21      ship_instr,
22      promo 
23   ) VALUES (
24      order_rec.store_num,
25      order_rec.order_num,
26      order_rec.order_date,
27      order_rec.fac_code,
28      order_rec.ship_instr,
29      order_rec.promo 
30   )
31   WHENEVER ERROR STOP
32   IF SQLCA.SQLCODE <> 0 THEN
33      CLEAR FORM
34      CALL __mbox_ok(title1,SQLERRMESSAGE,"stop")
35      RETURN FALSE
36   END IF
37   CALL arr_ordnums.insertElement(1)
38  LET arr_ordnums[1] = order_rec.order_num 
39   CALL arr_items.clear()
40   MESSAGE msg11
41   RETURN TRUE
42 END FUNCTION
Note: