Multiple queries writing to single record

Hi to everyone.

I'm developing application for storage management
and I have one general problem. When I decrease number
of articles with one query, in the same time other query
could decrease the same record before the first query has
finished. In this occasion exception will occur. How my
program to process it so number of articles to be right.