Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: How to increased by exactly 1 ?

Re: How to increased by exactly 1 ?

From: Sergey Balter <balter_at_kompas.donetsk.ua>
Date: Fri, 21 Jan 2005 20:33:10 +0200
Message-ID: <csrhte$2fi$1@news.dc.ukrtel.net>


> The system need to auto generate the Control Code column for the items.
> The
> business rule is that the system should have an option to assign the
> lowest
> next available Control Code for the new item created.
Is it so neccessary to follow to business rule literally ? Look then...

  1. It's possible to remove the item from inventory isn't it? Then you obtain a hole in numeration - have you think about that?
  2. Usually there is a gap between allocation of Control Code for an item and saving the item into database. I mean the following steps: user clicks adding new item, then user obtains new empty record or card. At this point user must already see new Control Code. Then your program must allocate new Code for this new record. In this point of time another user adds new item. After that the first user can cancel item adding and discard changes! Then again you'll got a hole, a gap...

I advise you to discuss this problem with the person that define that business rule.

The are no good efficient scalable solution in this case... In fact, you must create some semaphore to serialize access to your ControlCodeCounter. You can use for that purpose DBMS_LOCK package,
or use SELECT FOR UPDATE statement

In any case, it will work only if just few person simultaneously add items... Received on Fri Jan 21 2005 - 12:33:10 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US