increment a sequence number

goslows

New Member
I have a sequence variable in a table of my database and want to increment it everytime I add a transaction to a field in the table with the sequence. I am having a hard time trying to do this in 9.1C. In version 8 I did this in the local-assign by defining a buffer and looking up the last sequence number before incrementing it. Where do I do this in 9.1C?
 
There is probably an equivalent place to do this in v9 (I am v8 based, so I dont know what that is), but it would make more sense to me to have this in a create trigger for the table. If you look in the sports database, there is an example of this for the Customer table. Also, it sounds like you are using the CURRENT-VALUE function to get the sequence value, then adding 1 to it and then writing it back to the sequence. There is no need to do this, the NEXT-VALUE increments the sequence and then returns that value

Code:
/***************************************************************************\
*****************************************************************************
**
**	 Program: crcust.p
**	Descript:
**
*****************************************************************************
\***************************************************************************/
TRIGGER PROCEDURE FOR Create OF Customer.
/* Automatically Increment Customer Number using Next-Cust-Num Sequence */
ASSIGN Customer.Cust-Num = NEXT-VALUE(Next-Cust-Num).

goslows said:
I have a sequence variable in a table of my database and want to increment it everytime I add a transaction to a field in the table with the sequence. I am having a hard time trying to do this in 9.1C. In version 8 I did this in the local-assign by defining a buffer and looking up the last sequence number before incrementing it. Where do I do this in 9.1C?
 
Back
Top