Re: Problems handling errors in PL/pgSQL

From: "Joe Conway" <jconway2(at)home(dot)com>
To: "Josh Berkus" <josh(at)agliodbs(dot)com>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Problems handling errors in PL/pgSQL
Date: 2001-04-23 23:11:53
Message-ID: 038201c0cc4a$ca55f110$96d410ac@jecw2k1
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

> However, not all types of errors are so trapped. The most problematic
> un-trapped error is referential integrity: if an INSERT or UPDATE fails
> because of a referential integrity violation, the PL/pgSQL function will
> still see the statement as a success and not error out. Example:
>

I'm not sure if this is what you're looking for, but in 7.1 you can do
something like:

INSERT INTO bar(barpk,foopk) VALUES(barpkval,foopkval);
GET DIAGNOSTICS rows = ROW_COUNT;
-- do something based on rows --

See "24.2.5.4. Obtaining other results status" at
http://postgresql.readysetnet.com/users-lounge/docs/7.1/postgres/plpgsql-des
cription.html.

Hope this helps,

Joe

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Josh Berkus 2001-04-23 23:31:19 Re: Problems handling errors in PL/pgSQL
Previous Message Hans-Jürgen Schönig 2001-04-23 21:02:56 SET SEQSCAN TO OFF - error