Subject Re: [ib-support] limit the number of records?
Author Paul Schmidt
On 26 Mar 2002 at 16:06, Daniel Bertin wrote:

> Hi all,
> I'm a little puzzled,
> I would like to limit the number of records a user can enter into a
> table, and am looking for suggestions on how I should accomplish this.
> A routine on the client or on the server? on the client counting the
> number of records, how often or when should I count? on the server
> with a stored procedure, executed at certain intervals or on a
> trigger? I would like to stop the user from entering anymore records
> into a table after he has reached a certain limit(#of records). I'm
> using D5,IBO,FB1, Would someone have a suggestion on how I should
> accomplish this task? Thanks in advance Daniel
>

Some more info is needed, for example if user JBLOUGH is allowed to enter 75
records, is that a permanent limit, or can they add more records another time?
What if he/she/it deletes 5 records, can they then add 5 more new ones?

The best way I know of, is to use a before insert trigger on the data entry table, and
add a new table to track the entries. Optionally you can do the check either within
the trigger (by raising an event on failure) or by having the client program do a
comparison, before adding a record. By using a trigger you eliminate the ability for
a client to get around the process by using multiple work stations. I don't use events
myself, but I think that would result in cleaner code, and be a little quicker. If a
delete will effectively increase the limit, then add a after delete trigger that
decrements your counter.

PaulPaul Schmidt
Tricat Technologies
paul@...
www.tricattechnologies.com