Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Limit number of Rows in a table

Re: Limit number of Rows in a table

From: Keith Boulton <kboulton_at_ntlworld.com>
Date: Sat, 21 Jul 2001 21:27:14 GMT
Message-ID: <6if6kt85hqus2rbrh4rh8hia2cjbjkr16o@4ax.com>

On 03 Jul 2001 16:39:13 +0200, Marco Wolfgarten <mwolfgarten_at_web.de> wrote:

>Hi there!
>
>
>I'm trying to limit the number of rows in a table -> No INSERT must be possible.
>I tried to do this using a trigger, but I have no idea to forbid the
>transaction:
>
>
>create or replace trigger trg_limit_Customers before INSERT ON tbl_Customers
>declare
> numRows integer;
>begin
> SELECT Count(*) into numRows from tbl_Customers;
> if numRows>25 then
> ????? --Do not allow to insert more rows!
> end if;
>end;
>
>

Others have said how to do the counting and raise the error, but shouldn't the trigger be an AFTER insert. Otherwise if there were 25 rows in the table before the insert, one could insert 1 million rows. Received on Sat Jul 21 2001 - 16:27:14 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US