From: Aftab Alam <aalam@tatashare.com>
To: 'Richard Huxton' <dev@archonet.com>
Cc: pgsql-general@postgresql.org
Subject: Re: trigger
Date: Sat, 19 Nov 2005 13:14:00 +0530
Message-ID: <002101c5ecdd$03071310$ec1010ac@aftabn463> (raw)
In-Reply-To: <437DD8B0.6030509@archonet.com>
Hi there,
CREATE TABLE emp_mas
(
emp_com_cd char(2) NOT NULL,
emp_loc_cd numeric NOT NULL,
emp_cd numeric NOT NULL,
emp_sal numeric,
emp_m_name varchar(50),
emp_full_name varchar(50),
emp_sex varchar(1)
)
delete from emp_mas where emp_com_cd = 'KB' and emp_loc_cd = 1 and emp_cd
in (1,2);
insert into emp_mas values ('KB', 1, 1,1,'aftab','aftab alam','M');
insert into emp_mas values ('KB', 1, 1,2,'amit','amit sharma','M');
in the above statement if aftab is already available in the database then
the trigger does not allowing to delete the data for the database if not
insert statement is going to fire.
wating for reply.
thanks & regrds,
aftab
-----Original Message-----
From: pgsql-general-owner@postgresql.org
[mailto:pgsql-general-owner@postgresql.org]On Behalf Of Richard Huxton
Sent: Friday, November 18, 2005 7:06 PM
To: aalam@tatashare.com
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] trigger
Aftab Alam wrote:
> Hello,
>
> 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.
Aftab - can you explain in some more detail. Raising an error on an
insert will happen automatically if you violate a unique constraing.
What is this "next insert statment" you're talking about?
--
Richard Huxton
Archonet Ltd
---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly
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: aalam@tatashare.com, dev@archonet.com
Subject: Re: trigger
In-Reply-To: <002101c5ecdd$03071310$ec1010ac@aftabn463>
References: <437DD8B0.6030509@archonet.com> <002101c5ecdd$03071310$ec1010ac@aftabn463>
* 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