pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: ON.KG <skyer@on.kg>
To: pgsql-general@postgresql.org
Subject: Trigger before insert
Date: Thu, 25 Nov 2004 14:37:40 +0300
Message-ID: <9414883125.20041125143740@on.kg> (raw)
In-Reply-To: <41A584EE111.0263KG@129.180.47.120>
References: <200411251400.32752.jerome@gmanmi.tv>
	<41A584EE111.0263KG@129.180.47.120>

Hi all,

===================================
CREATE FUNCTION trigger_test_func()
RETURNS trigger
AS '
 DECLARE
 cnt int4;
 
 BEGIN
   SELECT INTO cnt COUNT(*)
   FROM table_test
   WHERE ip = new.ip;

   IF cnt > 50 THEN
     -- THERE THE "INSERT" HAS TO BE STOPED
   END IF;

   RETURN new;
 END;'
LANGUAGE 'plpgsql';

CREATE TRIGGER trigger_test
BEFORE INSERT
ON table_test
FOR EACH ROW
EXECUTE PROCEDURE trigger_test_func();
===================================

How could i stop Inserting record into table by some condition?

Thanx!




view thread (3+ messages)  latest in thread

Message-ID: <9414883125.20041125143740@on.kg>
Permalink:  ../9414883125.20041125143740@on.kg/
Also on:    postgresql.org/message-id/9414883125.20041125143740@on.kg

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: skyer@on.kg, pgsql-general@postgresql.org
  Subject: Re: Trigger before insert
  In-Reply-To: <9414883125.20041125143740@on.kg>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox