Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id DDA379FB459 for ; Thu, 5 Apr 2007 06:47:14 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 74620-07 for ; Thu, 5 Apr 2007 06:47:07 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from smtpout26.attiva.biz (smtpout26.attiva.biz [85.37.16.27]) by postgresql.org (Postfix) with ESMTP id 01BCF9FA13B for ; Thu, 5 Apr 2007 06:47:10 -0300 (ADT) Received: from FBCMFE02B07.fbc.local ([192.168.30.95]) by smtpout26.attiva.biz with Microsoft SMTPSVC(6.0.3790.1830); Thu, 5 Apr 2007 11:47:09 +0200 Received: from dream ([88.34.161.130]) by FBCMFE02B07.fbc.local with Microsoft SMTPSVC(6.0.3790.1830); Thu, 5 Apr 2007 11:47:08 +0200 Message-ID: <008801c77767$7109c130$1102a8c0@dream> Reply-To: "Shavonne Marietta Wijesinghe" From: "Shavonne Marietta Wijesinghe" To: References: <005b01c7775d$c4fa4b70$1102a8c0@dream> <20070405085343.GF24814@a-kretschmer.de> <007601c77764$2b2a0ec0$1102a8c0@dream> Subject: Re: Insert only if not found Date: Thu, 5 Apr 2007 11:47:35 +0200 Organization: Studio FORM MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=response Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.3028 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028 X-OriginalArrivalTime: 05 Apr 2007 09:47:08.0940 (UTC) FILETIME=[609A24C0:01C77767] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200704/71 X-Sequence-Number: 28071 I think i spoke to soon. It works. But if i change a letter from capital to simple it inserts my record 2 times. So i have 2 records for "Shavonne" and "shavonne". So i thought i would do the select in uppercase. 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) SELECT '127001200745114035', '', 'chan', 'micia', 'F', '', '', '01/05/2006', '', '', '', '', 'demo', '05/04/2007', '11.40.35' WHERE NOT EXISTS (SELECT upper(TE_COGNOME), upper(TE_NOME), upper(TE_SESSO), TE_DTNASC FROM MOD48_02 WHERE TE_COGNOME='CHAN' AND TE_NOME='MICIA' AND TE_SESSO='F' AND TE_DTNASC='01/05/2006'); but this doesn't work. I don't know why. If i try only the part SELECT upper(TE_COGNOME), upper(TE_NOME), upper(TE_SESSO), TE_DTNASC FROM MOD48_02 it returns me the fields in UPPERCASE. It's really strange why it doens't work all together. Anyone? ----- Original Message ----- From: "Shavonne Marietta Wijesinghe" To: Sent: Thursday, April 05, 2007 11:24 AM Subject: Re: [SQL] Insert only if not found > wow thanks. i managed to paste it to fit my code.. > yeahhhh ^____^ > > Shavonne Wijesinghe > www.studioform.it > > > ----- Original Message ----- > From: "A. Kretschmer" > To: > Sent: Thursday, April 05, 2007 10:53 AM > Subject: Re: [SQL] Insert only if not found > > >> 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 >> >> ---------------------------(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 > > > ---------------------------(end of broadcast)--------------------------- > TIP 7: You can help support the PostgreSQL project by donating at > > http://www.postgresql.org/about/donate