Subject Re: [ib-support] limit the number of records?
Author Lista de Discução Interbase
If I get what you want you could do something like this:

This is only a "road map", the code below *will not compile*, it's just to
see if a get what you want, if it's what you want tell me and I will
produce a "workable code".

The code below will teste in a trigger (before insert) if the quantity of
record inserted in the last hour is greater than some limit. Or do you
prefer some kind of "human reset" so only the "administrator" could say
"Ok. Joe go ahead now you can insert a more "X" records". You could create
another table that holds periods (even slices of days) and the quantity of
records that some user could insert, I don't know the intention for this
check, but there are a lot of ways to get this work.

Create Table Friend( Name varchar(50),
Phone varchar(30),
UserID integer,
TimeStamp Date); -- NOTE Dialect 1 here

in the before insert trigger you could put something like this:

Select
count(*)
from
Friend
where
UserID = New.UserID and
(Now - TimeStamp) < (1/24) -- for a hour period
into
:Qtd

if Qtd > 10
Raise Exception


HTH

Alexandre

At 16:06 26/03/02 -0800, you 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