pg.ddx.io pgsql-sql@postgresql.org mailing list archivehelp / color / mirror / Atom feed
System Messages 2+ messages / 2 participants [nested] [flat]
* System Messages @ 2002-02-27 15:39 Samuel J. Sutjiono <ssutjiono@wc-group.com> 0 siblings, 1 reply; 2+ messages in thread From: Samuel J. Sutjiono @ 2002-02-27 15:39 UTC (permalink / raw) To: pgsql-sql; pgsql-general@postgresql.org 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. ^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: System Messages @ 2002-02-27 19:14 Gregory Wood <gregw@com-stock.com> parent: Samuel J. Sutjiono <ssutjiono@wc-group.com> 0 siblings, 0 replies; 2+ messages in thread From: Gregory Wood @ 2002-02-27 19:14 UTC (permalink / raw) To: Samuel J. Sutjiono <ssutjiono@wc-group.com>; +Cc: PostgreSQL-General <pgsql-general@postgresql.org> 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. ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2002-02-27 19:14 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2002-02-27 15:39 System Messages Samuel J. Sutjiono <ssutjiono@wc-group.com> 2002-02-27 19:14 ` Gregory Wood <gregw@com-stock.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox