X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9192BDBB9F for ; Sat, 19 Nov 2005 03:50:34 -0400 (AST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 76025-06 for ; Sat, 19 Nov 2005 07:50:34 +0000 (GMT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from smtp1.netmagicians.com (smtp1.netmagicians.com [202.87.39.91]) by svr1.postgresql.org (Postfix) with ESMTP id 6BC95DBAD8 for ; Sat, 19 Nov 2005 03:50:31 -0400 (AST) Received: from mailserver.tatashare.com (unknown [202.149.193.242]) by smtp1.netmagicians.com (Postfix) with ESMTP id 26BFF374403; Sat, 19 Nov 2005 13:20:20 +0530 (IST) Received: from aftabn463 (unknown [172.16.16.236]) by mailserver.tatashare.com (Postfix) with SMTP id 8FED73E568E; Sat, 19 Nov 2005 13:15:57 +0530 (IST) Reply-To: From: "Aftab Alam" To: "'Richard Huxton'" Cc: Subject: Re: trigger Date: Sat, 19 Nov 2005 13:14:00 +0530 Message-ID: <002101c5ecdd$03071310$ec1010ac@aftabn463> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook CWS, Build 9.0.2416 (9.0.2910.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 In-Reply-To: <437DD8B0.6030509@archonet.com> X-NetMagic-MailScanner-Information: Powered By NetMagic Mail Protection v1.0 X-NetMagic-MailScanner: Found to be clean X-NetMagic-MailScanner-From: aalam@tatashare.com X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.001 required=5 tests=[AWL=0.001] X-Spam-Score: 0.001 X-Spam-Level: X-Archive-Number: 200511/975 X-Sequence-Number: 87119 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