Received: from gw.acate.com.br ([200.215.17.89]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id e9VHGTl83051 for ; Tue, 31 Oct 2000 12:16:30 -0500 (EST) (envelope-from edmar@brasmap.com) Received: from ana ([192.168.1.13]) by gw.acate.com.br (8.9.3/8.9.3) with SMTP id PAA32540; Tue, 31 Oct 2000 15:16:16 -0200 From: "Edmar Wiggers" To: "Petr Jezek" Cc: Subject: RE: INSERT [IGNORE] INTO TABLE Date: Tue, 31 Oct 2000 15:19:07 -0200 Message-ID: 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 IMO, Build 9.0.2416 (9.0.2910.0) In-Reply-To: X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 Importance: Normal X-Archive-Number: 200010/27 X-Sequence-Number: 27 > > Check existence and then insert or update. If you want, I guess > you could > > wrap that inside a stored procedure. > > > Well, that's a good idea :-) but I'm not sure about how to create > such procedure. I would appreciate Your help. Quite frankly, I'm not sure either. I'm just starting with PostgreSQL, what I really know is Oracle. I believe it would be something like ... [declare routine, with one argument per record field] ... if exists(select 1 from table_name where [field_key] = [arg_key]) then update table_name set field1 = arg1,...,fieldn = argn where field_key = arg_key; else insert into table_name (field1,...,fieldn) values (arg1,...,argn); end if; ... The syntax is probably off, but that's the idea. I used that several times on oracle.