PostgreSQL 8.0.0beta5 Documentation
Chapter 35.9 bottom of the page.
"RAISE EXCEPTION presently always generates the same SQLSTATE code,
P0001, no matter what message it is invoked with. It is possible
to trap this exception with EXCEPTION ... WHEN RAISE_EXCEPTION THEN ...
but there is no way to tell one RAISE from another. "
It would seem a kludge would be to set a variable at each point of possible
failure, such as continuously incrementing a variable as it goes through the
code. You would then be able to use a standard case statement or call an
error message function to return a meaningful error message.
In any case, the documentation very clearly says you can't do it.
<postgresql@bryden.co.za> wrote in message
news:43109.127.0.0.1.1111671666.squirrel@127.0.0.1...
> Hi Bruno
>
> There are a lot of the topics that I feel could have better (or more
> comprehensive examples). In particular I am thinking of plpgsql. One
> example is information about working with Exceptions (postgresql specific)
> and another is the small amount of info about the RAISE Statement.
>
> Refering to my mention of exceptions above, the following is information
> that I could not find in the standard docs:
> How to use(Return using RAISE) the actual exception code and message once
> you have handled the error. This is especially usefull if you have used
> WHEN OTHERS to catch the error.
>
> Thanks
> Craig
>
> > On Thu, Mar 24, 2005 at 14:37:59 +0200,
> > postgresql@bryden.co.za wrote:
> >> Hi
> >>
> >> I am new to PostgreSQL and find that the standard documentation is very
> >> thin. I would like to buy a more comprehensive book. All the available
> >> books seem very out of date!!! Firstly, does it matter if I buy a book
> >> that was published in Feb 2003? Will such a book be hopelessly out of
> >> date?
> >
> > What parts of the documentation do you find thin? Without knowing what
> > you need extra info on, it will be hard to recommend other
documentation.
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 5: Have you checked our extensive FAQ?
> >
> > http://www.postgresql.org/docs/faq
> >
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings
>