Setup up a Database "Waiting List" or Queue

  • Thread starter Thread starter poppybush
  • Start date Start date
P

poppybush

I am working on a windows application that allows a system
administrator to assign users to specific software titles. Let's say
that there are 5 available licenses for Visual Studio but 6 users need
the software at one time. What I did was create an OC table
(out-of-compliance) and added the 6th person to that table. I've also
created a feature in the software that allows the admin to add
additional licenses to the database. Is there a way to configure the
tables to add 2 users from the OC table to the SoftwareUsers table when
additional licenses are added? I'll try to explain it more in-depth:

3 licenses available for VS
4 People need VS
3 People written to SoftwareUsers table
1 Person written to OC table

System admin adds 1 more instance of VS
Person in OC gets moved to SoftwareUsers table

I can see this using some sort of SELECT TOP X where SoftwareTitle =
"VS...." but don't know the easiest way to implement it.
 
Try this approach...

Put in a database trigger on the table that tracks how many liscenses you
have. When the number of liscenses changes (eitehr increased or decreased)
find the difference in liscenses (+x or -x) and then move the users from the
liscensed table to the OC table.

compare the old liscense count to the new to get X
if x is zero (liscence count hasnt changed, you are done)

Create cursors to select the top X values from either table for the
application in question. Which cursor you call depends on whether liscenses
were added or removed.

insert records into the appropriate table and delete them from the original
table

This appraoch should handle it for you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top