Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id D2CC69FBCAC for ; Thu, 5 Apr 2007 05:53:57 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 51198-05 for ; Thu, 5 Apr 2007 05:53:48 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.183]) by postgresql.org (Postfix) with ESMTP id 5E2939FB9BD for ; Thu, 5 Apr 2007 05:53:51 -0300 (ADT) Received: from [194.25.154.138] (helo=webserv.wug.de) by mrelayeu.kundenserver.de (node=mrelayeu0) with ESMTP (Nemesis), id 0MKwh2-1HZNiy2mTX-0003y8; Thu, 05 Apr 2007 10:53:45 +0200 Received: from kretschmer by webserv.wug.de with local (Exim 3.36 #1) id 1HZNix-00088h-00 for pgsql-sql@postgresql.org; Thu, 05 Apr 2007 10:53:43 +0200 Date: Thu, 5 Apr 2007 10:53:43 +0200 From: "A. Kretschmer" To: pgsql-sql@postgresql.org Subject: Re: Insert only if not found Message-ID: <20070405085343.GF24814@a-kretschmer.de> References: <005b01c7775d$c4fa4b70$1102a8c0@dream> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <005b01c7775d$c4fa4b70$1102a8c0@dream> X-OS: Debian/GNU Linux - weil ich es mir Wert bin! X-Message-Flag: "Windows" is not the answer. "Windows" is the question and the answer is "no"! User-Agent: Mutt/1.5.9i X-Provags-ID: V01U2FsdGVkX19l4njQqYZ5nzYMpUtZ547ltCu6CVnaAAaL7GM aJh49g/4LcfgCrPfsc3qRuJU4v4X7+SwXU+anipbEO3tkIgL9o AbSM9Iy1AUK/xi4egWp1xGl837k5Ggq X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200704/69 X-Sequence-Number: 28069 am Thu, dem 05.04.2007, um 10:38:21 +0200 mailte Shavonne Marietta Wijesinghe folgendes: > Hello everyone.. > > Here is the result of my Insert. and also the insert works ok. > > INSERT INTO MOD48_02 (ID, TE_INDI, TE_COGNOME, TE_NOME, TE_SESSO, TE_ATTNASC, > TE_LUONASC, TE_DTNASC, TE_PROVSTATO, TE_PROV, TE_PATERNITA, TE_RICHIESTA, > USERNAME, DATE_INSERTED, TIME_INSERTED) VALUES ('127001200745101033', > 'england', 'bloom', 'orlando', 'M', 'ww', 'florida', '05/06/1984', 'america', > 'UK', 'xx', 'no', 'demo', '05/04/2007', '10.10.33'); > But before i insert this record i want to check if the it hasn't been inserted > before. I want to use the following fields as the riefferent. TE_COGNOME, > TE_NOME, TE_SESSO, TE_DTNASC > > And if there is no record to match those 4 fields i want to insert it else just > a message saying that the record has been inserted b4. > > any idea to start with? Yes, read this: http://ads.wars-nicht.de/blog/archives/11-Avoid-Unique-Key-violation.html I think, you can change this for your request. (but without the message, if you really need this message, you should use a function and RAISE a NOTICE as the message) Andreas -- Andreas Kretschmer Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header) GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net