Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 336515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:14:59+00:00 2026-05-12T10:14:59+00:00

A little presentation for what I want to do: Consider the case where different

  • 0

A little presentation for what I want to do:

Consider the case where different people from a firm get, once a year, an all expenses paid trip to somewhere. There may be 1000 persons that could qualify for the trip but only 16 places are available.

Each of this 16 spots has an associated index which must be from 1 to 16. The ones on the reservation have index starting from 17.

The first 16 persons that apply get a definite spot on the trip. The rest end up on the reservation list. If one of the first 16 persons cancels, the first person with a reservation gets his place and all the indexes are renumbered to compensate for the person that canceled.

All of this is managed in a Java web app with an Oracle DB.

Now, my problem:

I have to manage the index in a correct way (all sequential, no duplicate indexes), with possible hundreds of people that simultaneously apply for the trip.

When inserting a record in the table for the trip, the way of getting the index is by

SELECT MAX(INDEX_NR) + 1 AS NEXT_INDEX_NR FROM TABLE

and using this as the new index (this is done Java side and then a new query to insert the record). It is obvious why we have multiple spots or reservations with the same index. So, we get, let’s say, 19 people on the trip because 4 of them have index 10, for example.

How can I manage this? I have been thinking of 3 ways so far:

  1. Use an isolation level of Serializable for the DB transactions (don’t like this one);
  2. Insert a record with no INDEX_NR and then have a trigger manage the things… in some way (never worked with triggers before);
  3. Each record also has a UPDATED column. Could I use this in some way? (note that I can’t lose the INDEX_NR since other parts of the app make use of it).

Is there a best way to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T10:14:59+00:00Added an answer on May 12, 2026 at 10:14 am

    Why make it complicated ?

    Just insert all reservations as they are entered and insert a timestamp of when they resevered a spot.

    Then in you query just use the timestamp to sort them.

    There is offcourse the chance that there are people that reserved a spot at the very same millisecond then just use a random method to assign order.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

little help guys im still a newbie at c++ error: invalid conversion from 'VboVO*
I'm a little confused by the meaning of Aliasing between CPU-cache and Physical address
I'm about to manage an application that has a clint with a web presentation
See the following XAML: <UserControl xmlns:sdk=http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk x:Class=SilverlightApplication1.MainPage xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:d=http://schemas.microsoft.com/expression/blend/2008 xmlns:mc=http://schemas.openxmlformats.org/markup-compatibility/2006 mc:Ignorable=d d:DesignHeight=300 d:DesignWidth=400
hey there, i have written a custom control for my App so things get
Little bite background: I joined a software company three years ago after graduated with
Little to say ill just paste my code hoping that someone will see what
I'm looking for recommendations on how to do some reporting in PHP. Specifically, I
I read this post and I really like this solution to templating but I
I have an image viewer created with WPF 3D graphics. Image quality is really

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.