This topic is locked

controlled consecutives

5/25/2011 1:05:37 PM
PHPRunner General questions
N
Nir Frumer author

hi

I need to assign a consecutive number in orders

my order has it's key field orderId and a controlled consecutive OrderNo

each time a user saves a new order I would like to assign the corresponding OrderNo value from consecutives.orders

(consecutives is another table within my project) and increment consecutives.orders by 1.

how can I do it??
thanks in advance,

Nir.

Sergey Kornilov admin 5/25/2011

Nir,
you can use something like this in BeforeAdd event of this table:

$rstmp = CustomQuery("select max(OrderNo)+1 as m from orders");

$datatmp = db_fetch_array($rstmp);

$values["OrderNo"] = $datatmp["m"];