/* crcust.p */
TRIGGER PROCEDURE FOR Create OF Customer.
/* Automatically Increment Customer Number using Next-Cust-Num Sequence */
ASSIGN Customer.Cust-Num = NEXT-VALUE( Next-Cust-Num ).
DEF VAR I AS INT.
I = NEXT-VALUE( Next-Cust-Num ).
FIND CUSTOMER WHERE CUST-NUM = I NO-LOCK NO-ERROR.
DO WHILE AVAIL CUSTOMER:
I = NEXT-VALUE( Next-Cust-Num ).
FIND CUSTOMER WHERE CUST-NUM = I NO-LOCK NO-ERROR.
END.
CREATE CUSTOMER.
ASSIGN Customer.Cust-Num = I.
@sdjensen:
this is like my prev method, and sadly it's not working when concurency occurs.
Thanks for your reply too![]()