Subject | How can i update multiple rows after a delete? |
---|---|
Author | fabioxgn |
Post date | 2005-11-18T17:45:48Z |
Hi all, i m making a little website for a store using firebird 1.5 and
php, and it have a stock control table.. so i m using a table with the
following fields:
id, product_id, action(add or remove), quantity and actual_stock
its kinda simple, my table data is like this:
id, pro_id, action, quantity, actual_stock
1, 01, A, 10, 0
2, 01, R, 1, 9
3, 01, R, 1, 8
4, 01, R, 1, 7
5, 01, R, 2, 5
6, 01, A, 5, 10
but my problem is... i have to somethimes remove a row, and i have to
rewrite all the atual_stock of the product.. like, if i remove the
second entry.. i have to do it:
id, pro_id, action, quantity, actual_stock
1, 01, A, 10, 0
2, 01, R, 1, 9<-Remove
3, 01, R, 1, 9<-Update
4, 01, R, 1, 8<-Update
5, 01, R, 2, 6<-Update
6, 01, A, 5, 11<-Update
So it have to update the rows after the one that was removed.. but i
dont have idea how to do it... my table should look like this after
the previuos delete:
id, pro_id, action, quantity, actual_stock
1, 01, A, 10, 0
3, 01, R, 1, 8
4, 01, R, 1, 7
5, 01, R, 2, 5
6, 01, A, 5, 10
btw. i cant figure out how to do it with firebird, i tried to think in
a solution but there are too many stuff to update.. as i m noob in
databasesi dont know how
Please, any help and ideas are welcome, hope you understand where i m
trying to get at ^^
Thanx in advance,
F�bio.
php, and it have a stock control table.. so i m using a table with the
following fields:
id, product_id, action(add or remove), quantity and actual_stock
its kinda simple, my table data is like this:
id, pro_id, action, quantity, actual_stock
1, 01, A, 10, 0
2, 01, R, 1, 9
3, 01, R, 1, 8
4, 01, R, 1, 7
5, 01, R, 2, 5
6, 01, A, 5, 10
but my problem is... i have to somethimes remove a row, and i have to
rewrite all the atual_stock of the product.. like, if i remove the
second entry.. i have to do it:
id, pro_id, action, quantity, actual_stock
1, 01, A, 10, 0
2, 01, R, 1, 9<-Remove
3, 01, R, 1, 9<-Update
4, 01, R, 1, 8<-Update
5, 01, R, 2, 6<-Update
6, 01, A, 5, 11<-Update
So it have to update the rows after the one that was removed.. but i
dont have idea how to do it... my table should look like this after
the previuos delete:
id, pro_id, action, quantity, actual_stock
1, 01, A, 10, 0
3, 01, R, 1, 8
4, 01, R, 1, 7
5, 01, R, 2, 5
6, 01, A, 5, 10
btw. i cant figure out how to do it with firebird, i tried to think in
a solution but there are too many stuff to update.. as i m noob in
databasesi dont know how
Please, any help and ideas are welcome, hope you understand where i m
trying to get at ^^
Thanx in advance,
F�bio.