From: | "Albe Laurenz" <laurenz(dot)albe(at)wien(dot)gv(dot)at> |
---|---|
To: | "Alain Roger *EXTERN*" <raf(dot)news(at)gmail(dot)com>, <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: returned value from SQL statement |
Date: | 2008-03-27 13:07:19 |
Message-ID: | D960CB61B694CF459DCFB4B0128514C201ED1BAC@exadv11.host.magwien.gv.at |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Alain Roger wrote:
> 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 ?
You can get almost every error message from an INSERT.
A few examples: 53100 (DISK FULL), 22004 (NULL VALUE NOT ALLOWED), ...
There could be a trigger or a rule involved which could
basically do anything in the database...
> 2. if the INSERT INTO is successful, how can i know it ? what
> is the returned value ?
"Returned" sounds like you are referring to a specific API.
Which programming language do you use?
An INSERT statement is successful iff it does not generate an error message.
Of course, this does not necessarily imply that something
was inserted - e.g., if there is an INSTEAD DO NOTHING rule
on the table.
> 3. the same question as point 2 but for all SQL statements
> from PostgreSQL.
Similar: an statement is successful iff it does not generate an error message.
I'd say that's the definition of a successful statement.
As to the return value, that depends on the kind of statement:
A DELETE (without RETURNING) or CREATE TABLE statement will not return rows,
while a SELECT or a DELETE ... RETURNING will.
Yours,
Laurenz Albe
From | Date | Subject | |
---|---|---|---|
Next Message | Brad Nicholson | 2008-03-27 13:09:45 | Re: page is uninitialized --- fixing |
Previous Message | Richard Huxton | 2008-03-27 12:45:46 | Re: Using tables in other PostGreSQL database |