Re: System Messages

From: "Gregory Wood" <gregw(at)com-stock(dot)com>
To: "Samuel J(dot) Sutjiono" <ssutjiono(at)wc-group(dot)com>
Cc: "PostgreSQL-General" <pgsql-general(at)postgresql(dot)org>
Subject: Re: System Messages
Date: 2002-02-27 19:14:02
Message-ID: 002f01c1bfc2$ecaa02d0$7889ffcc@comstock.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

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(at)postgresql(dot)org ; pgsql-general(at)postgresql(dot)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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tim Barnard 2002-02-27 19:24:33 Re: About vacuuming
Previous Message Pirtea Calin 2002-02-27 18:23:31 Re: descending index

Browse pgsql-sql by date

  From Date Subject
Next Message postgresql 2002-02-27 21:07:20 Re: Large Objects
Previous Message Wei Weng 2002-02-27 18:27:54 How slow is DISTINCT?