error handling codes - Mailing list pgsql-general

From Sim Zacks
Subject error handling codes
Date
Msg-id cv9lm6$he6$1@news.hub.org
Whole thread Raw
List pgsql-general
PostGresQL 8 beta1.
PGAdmin III beta 1.21

Is there a way to see what error code or error message occured when an error
happens?
I am trying to perform exception handling and a create view that included
another view that did not exist occured in a plpgsql function.
I finally figured out that the error was Undefined_table, though that is
obviously not implicit.
The error I received was "relation "bob2" does not exist" There were no
error numbers or other indications that led me to the correct error code in
Appendix A of the documentation.
I could not find in the documentation if there is any functionality
available to the exception, such as exception.number, exception.message
etc.. Does duch a thing exist?

As an example here is the code I am testing. The view name was false on
purpose in this test so I could figure out how to handle it when I really
get a view that is wrong.

Thanks
Sim

create or replace function testexcept() returns void as
$$
begin
begin
create view dummy as
 select * from dummy2;
exception
 when UNDEFINED_TABLE then
  raise notice 'its an undefined table';
 when others then
  raise notice 'it is not an undefined table';
end;
return;
end;
$$ language 'plpgsql'



pgsql-general by date:

Previous
From: "Richard Crawley"
Date:
Subject: Method of building views
Next
From: Clodoaldo Pinto
Date:
Subject: Re: 7.4.6 FC2 MUCH slower from 2.6.9-1.11 to 2.6.10-1.8