Solved

Trigger insert sequence from defined set of values

Posted on 2011-03-08
3
542 Views
Last Modified: 2013-12-19
I am not quite sure how to describe it but I have an application where end users submit accounts to be worked and they all go in a table. I am in need of assigning these accounts to a group of ten other users for example. These ten users have their own personal user id's.

Thus when the account is inserted into the table a trigger needs to insert a specific user id in the "Assigned" column and do so in a sequence to ensure an equal number of accounts per person. Just not sure how to design this.

Thanks in advance.
0
Comment
Question by:mjfigur
3 Comments
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
Comment Utility
Round robin? So every 10th record is assigned to the same person?

Try the MOD operator against the sequence.

Not 100% accurate since sequences are not gapless but something like setting assigned to: Mod(sequence.nextval,10)
0
 
LVL 15

Accepted Solution

by:
Franck Pachot earned 500 total points
Comment Utility
Hi,

How do you need to manage concurrency and rollbacks ?
 - what if the transaction that inserts do not commit ? The user assignation is rolled back and the user should available for another assignation.
 - what if several concurrent inserts ? Each insert will not see the non-committed assignation, and finally when they all commit they will assign too much to a user.

Sequences (or random number) will be the most efficient, by result may not be balanced over users (gaps, rollbacks)

Keeping the number of assignation for each user in a table will solve that, but you will have concurrency issues (locks) when inserting.

Maybe you can change the design: instead of assigning at insert time, you should assign it when you query what the user has to work on: just pick the next 10 accounts from the queue (queue being the non-assigned accounts).

Regards,
Franck.
0
 

Author Closing Comment

by:mjfigur
Comment Utility
Thank you that is such a great idea. Will have it pull dynamically assigning them when they are requested will allow for my fluidity especially when one of the users may be out of the office on a given day or week.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now