From ssutjiono@wc-group.com Wed Feb 27 15:44:01 2002 Received: from qmsql.netservers.net (hpmail1.netservers.net [209.196.128.163]) by postgresql.org (Postfix) with SMTP id 7DDD2476C52 for ; Wed, 27 Feb 2002 10:44:01 -0500 (EST) Received: (qmail 51709 invoked from network); 27 Feb 2002 15:44:08 -0000 Received: from unknown (HELO AARON) (66.26.63.73) by hpmail1.netservers.net with SMTP; 27 Feb 2002 15:44:08 -0000 Message-ID: <00f701c1bfa4$f19b67c0$110a010a@headquarters.wcgroup.com> From: "Samuel J. Sutjiono" To: , Subject: System Messages Date: Wed, 27 Feb 2002 10:39:28 -0500 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_00F4_01C1BF7B.08608370" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 X-Archive-Number: 200202/1354 X-Sequence-Number: 21344 This is a multi-part message in MIME format. ------=_NextPart_000_00F4_01C1BF7B.08608370 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I have a function (stored procedures) that updates or inserts a customer re= cord (see below). IF found then=20 Update Customer=20 Set custname =3D icustname retmsg :=3D ''record already exists - updated''; ELSE=20=20=20=20 Insert into Customer (custname) VALUES (icustname); retmsg :=3D ''successful''; END IF; Can anybody tell me how I can be sure that the record is updated or inserte= d into the database ? Is there any system message in PostgreSQL that I can = query ? Thanks for your help.=20 ------=_NextPart_000_00F4_01C1BF7B.08608370 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
I have a function (stored procedures) = ;that=20 updates or inserts a customer record (see below).
 
IF found then
   Update=20 Customer 
   Set custname =3D icustname
   retmsg :=3D ''record already = exists -=20 updated'';
ELSE   
   Insert into=20 Customer (custname) VALUES (icustname);
   retmsg := =3D=20 ''successful'';
END IF;
 
Can anybody tell me how I can be sure that= the=20 record is updated or inserted into the database ? Is there any system messa= ge in=20 PostgreSQL that I can query ?
 
Thanks for your=20 help. 
------=_NextPart_000_00F4_01C1BF7B.08608370-- From gregw@com-stock.com Wed Feb 27 19:09:17 2002 Received: from mail.com-stock.com (mail.com-stock.com [204.255.137.254]) by postgresql.org (Postfix) with ESMTP id 75689476E09 for ; Wed, 27 Feb 2002 14:09:17 -0500 (EST) Received: by mail.com-stock.com (Postfix, from userid 1000) id 03FE195; Wed, 27 Feb 2002 14:06:27 -0500 (EST) Received: from deimos (deimos.com-stock.com [204.255.137.120]) by mail.com-stock.com (Postfix) with SMTP id 6F0D0D9EE; Wed, 27 Feb 2002 14:06:26 -0500 (EST) Message-ID: <002f01c1bfc2$ecaa02d0$7889ffcc@comstock.com> From: "Gregory Wood" To: "Samuel J. Sutjiono" Cc: "PostgreSQL-General" References: <00f701c1bfa4$f19b67c0$110a010a@headquarters.wcgroup.com> Subject: Re: System Messages Date: Wed, 27 Feb 2002 14:14:02 -0500 Organization: Comstock Net Services MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4807.1700 X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4807.1700 X-Archive-Number: 200202/1361 X-Sequence-Number: 21351 If there is an error, it should throw an exception that will stop the function. On the other hand, if you set a where clause on that UPDATE, then it might not actually modify any existing rows. In that case you can check the ROW_COUNT from GET DIAGNOSTICS to see if it modified any records (and however many). For more information on GET DIAGNOSTICS, check out: http://www7.us.postgresql.org/users-lounge/docs/7.2/postgres/plpgsql-stateme nts.html#PLPGSQL-STATEMENTS-DIAGNOSTICS Greg ----- Original Message ----- From: Samuel J. Sutjiono To: pgsql-sql@postgresql.org ; pgsql-general@postgresql.org Sent: Wednesday, February 27, 2002 10:39 AM Subject: [GENERAL] System Messages I have a function (stored procedures) that updates or inserts a customer record (see below). IF found then Update Customer Set custname = icustname retmsg := ''record already exists - updated''; ELSE Insert into Customer (custname) VALUES (icustname); retmsg := ''successful''; END IF; Can anybody tell me how I can be sure that the record is updated or inserted into the database ? Is there any system message in PostgreSQL that I can query ? Thanks for your help.