Re: returned value from SQL statement

From: Richard Huxton <dev(at)archonet(dot)com>
To: Alain Roger <raf(dot)news(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: returned value from SQL statement
Date: 2008-03-27 09:47:24
Message-ID: 47EB6D2C.3080508@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Alain Roger wrote:
> hi,
>
> i would like to know how can i control the returned value from a SQL
> statement ?
> for example, if i do an INSERT INTO... :
> 1. how can i know if the INSERT worked ?
> i mean i already trapped the unicity violation, but what if there is another
> error ? where can i get a complete list of exceptions ?
>
> 2. if the INSERT INTO is successful, how can i know it ? what is the
> returned value ?

If it fails you'll get an error. The transaction will be aborted. How
you access this error code will depend on what library/client you are using.

> 3. the same question as point 2 but for all SQL statements from PostgreSQL.

Same.

> I read few books and every time this part is not treated correctly but only
> partially.

There's a full list of error codes here if you want to know what went wrong:
http://www.postgresql.org/docs/current/static/errcodes-appendix.html

Am I mis-understanding you?

--
Richard Huxton
Archonet Ltd

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alain Roger 2008-03-27 09:48:39 Re: returned value from SQL statement
Previous Message Craig Ringer 2008-03-27 09:46:16 Re: returned value from SQL statement