From: "Phillips, Wesley" <[EMAIL PROTECTED]> > Hi all, > I have been working on a problem and worked out a solution, but am > wondering if there is an easier(more elegant?) way of doing it. I am > automatically generating configuration files for a Quality Of > Service(QOS) device, and each pipe in the QOS has a policy number > attached to it. The policy numbers must be unique, so I have to find > an unused number. The system never has more than 200 or so policies. I > am pulling the preexisting policy numbers out of a database and > placing them into an array(@addarr) Here is my code:
I'm not sure about mysql's abilities, but you might be able to do this within SQL with something like: select top 1 policy+1 from (select 0 as policy union all select policy from Table) as T1 where not exists (select * from Table as T2 WHERE T2.policy = T1.policy+1) order by policy (MS SQL syntax, I assume policies are numbered from 1) Jenda ===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz ===== When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]