translating this SQL query from a different dialect

From: Vanja <milosevski(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: translating this SQL query from a different dialect
Date: 2006-01-10 13:04:56
Message-ID: ed6f95fd0601100504g2516540ftc25280a394d60371@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

I have the following query which I would need to be able to use in
PostgreSQL. This basically limits the number of allowed rows in a
table to 8.

CREATE TRIGGER <TRIGGERNAME> ON [<TABLENAME>]
FOR INSERT AS
BEGIN DECLARE @<VARIABLENAME1> INT
SELECT <VARIABLENAME1> = COUNT (*) FROM <TABLENAME>
IF ( @<VARIABLENAME1>) > 8
BEGIN RAISERROR ('<ERROR MESSAGE>', 16, 1)
ROLLBACK TRANSACTION
RETURN
END
END

I've tried various combinations but none of them seem to work... any
help to convert this to PostgreSQL would be highly appreciated..

Thank you.

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Danjel Jungersen 2006-01-10 14:02:05 Re: Preventing access of user1 to user2's database
Previous Message Brendan Duddridge 2006-01-10 07:01:19 With auto vacuum, is analyze still necessary?