Subject | Re: [firebird-support] limit rows in a table |
---|---|
Author | Martijn Tonies |
Post date | 2005-08-25T15:02:07Z |
Hello Daniel,
CREATE TRIGGER check_for_too_many_rows ON <table> BEFORE INSERT
AS
DECLARE VARIABLE cnt INTEGER;
BEGIN
select count(*) from <table> INTO :cnt;
if (cnt = 1024)
then exception TOO_MANY_ROWS;
end
With regards,
Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, Oracle & MS SQL
Server
Upscene Productions
http://www.upscene.com
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com
> Could someone please suggest how I can limit the amount of rows aCREATE EXCEPTION TOO_MANY_ROWS 'too many rows';
> user
> can enter in a table, using a Stored Procedure or a trigger.
>
> I would like to limit the amount of rows to 1K, and all new inserts
> would be stopped/cancelled from this point on.
>
> How should I accomplish this?
CREATE TRIGGER check_for_too_many_rows ON <table> BEFORE INSERT
AS
DECLARE VARIABLE cnt INTEGER;
BEGIN
select count(*) from <table> INTO :cnt;
if (cnt = 1024)
then exception TOO_MANY_ROWS;
end
With regards,
Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, Oracle & MS SQL
Server
Upscene Productions
http://www.upscene.com
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com