"hatethisnamegame" <webforumsuser@macromedia.com> wrote
in message
news:fh0q9k$dvj$1@forums.macromedia.com...
> UPDATE tblProducts
> SET QuantityInStock = QuantityInStock - %QuantityOrdered
> WHERE ProductID = %ProductID
>
> You may have to do a loop through all of the items in
the order and run
> the
> above for each item
Yes that's another way to do it, however if you instruct the
database to
update multiple records at once it will be able to optimize
that operation.
Look at the delete with join statement, you can prevent a lot
of data from
leaving and entering the process boundary of the database
(for each update
you have to retrieve productid, Quantity in stock and pass
them in again,
and the SQL has to be parsed every time).
In general try to perform as many operations as possible
using a single
statement and try to keep them woithin the database engine,
the point of a
database is to store, process and retrieve your data as
efficiently as
possible.
Joris