Hi All, My java generates a code say 'Job 1'. The databse has 5(dynamic no of) executives say'E1','E2','E3','E4','E5' etc. So when 'Job 1' is generated by the system, it should be assigned to the 'E1'. Similarly, 'Job 2' ---- 'E2' 'Job 3' ---- 'E3' 'Job 4' ---- 'E4' 'Job 5' ---- 'E5' 'Job 6' ---- 'E1' and so on. Could anyone please suggest an algorithm for this. Thanks.
As I can understand from your question, the Executives are only 5 and jobs can be any number. So if you are sure that all your job names will be as Job1,Job2,....Job25,... you can hard code this "Job" while creating a substring of that variable and get only the number. As,
Now you can easily get the executive from the database I suppose. This is the logic which came first to mind may be there is some other easy way. Hope this will do the job for you Regards [ May 13, 2003: Message edited by: Abhilash Vasudevan ]
Hi Abilash, Any thanks. But the 'Job 1' may be 'A1' or 'B30' or '. C60'. The above code is dynamic. the executives are also dynamic.Today there are 5 Executives, it may increase. Pl. suggest a table sturcture. Thanks
Hi, I am not so sure that I have understood your scenario properly. Still assuming that you will be generating job after job and these have to be distributed among executives in the database uniformly, i would suggest the following. Create a table of executives where there are fields alloted_jobs and completed_jobs (number datatypes) other than name, id, etc. Each time you come across a new job just check the least value of alloted_jobs-completed_jobs (the difference) for each executive and allot it to that person. By doing so you will be loading all your executives almost uniformly. Take care to increase the alloted_jobs field by 1 as soon as you allot a new job and to increase the completed_jobs by 1 when it is reported completed. Also you can get the least alloted persons list in an alphabetical or id wise order so that you can take the first person from the select always,if there are more than one with the least allots. This saves from making a logic to give the jobs one after other executives. Regards