From: Stefan Balzter <Email@SteBaSoft.de>
To: aalam@tatashare.com
To: pgsql-general@postgresql.org
Subject: Re: trigger
Date: Fri, 18 Nov 2005 16:05:40 +0100
Message-ID: <437DEDC4.6010401@SteBaSoft.de> (raw)
In-Reply-To: <001101c5ec31$c16b1420$ec1010ac@aftabn463>
References: <001101c5ec31$c16b1420$ec1010ac@aftabn463>
Aftab Alam schrieb:
> I want to create a trigger in PostgresSQL
>
> In trigger, Before inserting the record, if data is already in the
> table, the trigger fire the mesaage that data is already there, and
> after that trigger ckeck for next insert statement.
You write a function that returns the type "trigger" and checks whether
the data is already there (i.e. by SELECTing INTO a variable the number
of records with your given values and checking if the variable is >0).
If it is, let it shout out your NOTICE and RETURN NULL; if it's not,
RETURN NEW;
Afterwards, you create the actual trigger BEFORE INSERT ON your table
FOR EACH ROW and let it execute your recently written function :-)
Good luck,
Stefan Balzter
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: Email@SteBaSoft.de, aalam@tatashare.com
Subject: Re: trigger
In-Reply-To: <437DEDC4.6010401@SteBaSoft.de>
References: <001101c5ec31$c16b1420$ec1010ac@aftabn463> <437DEDC4.6010401@SteBaSoft.de>
* 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