0

When there is two users sitting on table 4 and placed orders even at the same time they should get the same bill id. but the actuall thing happening from our exection is they are getting two different bill ids.

when user A placed order, sql checks for table number existence and at the same time user B also place order and check for table 4 existence though sql so both the users do not find table 4 existence so the new bill id is created for both orders.

if we can know the user B has placed order for the same table number 4 we could assign the same bill id.

ajay
  • 149
  • 1
  • 1
  • 5
  • 2
    Just put a restriction in your code somewhere so that the order can only be accepted once. That seems too obvious an answer, so I made it comment. Without some real code a better answer seems impossible to me. – KIKO Software May 02 '19 at 18:40
  • See https://stackoverflow.com/questions/40749730/how-to-properly-use-transactions-and-locks-to-ensure-database-integrity – Ugo T. May 02 '19 at 18:43
  • Possible duplicate of [How to properly use transactions and locks to ensure database integrity?](https://stackoverflow.com/questions/40749730/how-to-properly-use-transactions-and-locks-to-ensure-database-integrity) – Bruno Leveque May 02 '19 at 19:17
  • Why do you want to use the same ID for two different bills? That does not sound good - how do you want to distinguish these two orders? Anyways, if you don't want to let your database generate such IDs, what keeps you from generating them in your application based on the timestamp? – Nico Haase May 02 '19 at 19:20
  • because they are one group of family dining on table 4, required single bill for the payment. – ajay May 02 '19 at 19:22
  • when there is no row exist how could i perform row lock, because it is new order not yet bill id created for it – ajay May 02 '19 at 19:27

0 Answers0