FAQ
I want to trap this exception...

ERROR: nextval: reached maximum value of sequence

...and print a user friendly message. But I can't figure out what exception code to test
for. Example:

exception
when ??? then
raise exception 'Range too small.';

I looked through the postgres exception codes in the appendix, but couldn't find
the appropriate exception. WHY don't they match up the error message names??? Is there some
trick to making the connection from a psql error message to the related exception?
(So far I just go with past experience, but it would be nice if there was a system).

Help appreciated!!!

- Leon Starr

Search Discussions

  • Merlin Moncure at Jun 22, 2011 at 8:13 pm

    On Tue, Jun 21, 2011 at 11:13 PM, Leon Starr wrote:
    I want to trap this exception...

    ERROR:  nextval: reached maximum value of sequence

    ...and print a user friendly message.  But I can't figure out what exception code to test
    for.  Example:

    exception
    when ??? then
    raise exception 'Range too small.';

    I looked through the postgres exception codes in the appendix, but couldn't find
    the appropriate exception.  WHY don't they match up the error message names???  Is there some
    trick to making the connection from a psql error message to the related exception?
    (So far I just go with past experience, but it would be nice if there was a system).

    Help appreciated!!!
    it's object_not_in_prerequisite_state.

    A pretty effective way to figure this out is to actually just grep the
    code for the error message fragment and see what's being passed to
    ereport.

    merlin

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppgsql-novice @
categoriespostgresql
postedJun 22, '11 at 4:13a
activeJun 22, '11 at 8:13p
posts2
users2
websitepostgresql.org
irc#postgresql

2 users in discussion

Leon Starr: 1 post Merlin Moncure: 1 post

People

Translate

site design / logo © 2022 Grokbase