Search Postgresql Archives

Re: SQL error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



x asasaxax wrote:
HI everyone,


I´m trying to capture all the possible errors that a statement can have.
And, if there´s any error i will do a rollback; What i´m trying to do its:
BEGIN
  insert into temp values(1, 2, 3);
  IF ANY_ERROR_OCCURED THEN
     ROLLBACK;

Sorry, I didn't see the ROLLBACK statement there. Please disregard my previous reply; I thought you were trying to do something other than what you appear to be doing.

As Martijn van Oosterhout noted, the transaction will be put in an error state that ignores further commands. When in an error state, the transaction will treat COMMIT as ROLLBACK.

I assume you wish to attempt to do something and if it fails, abort the transaction and leave everything in a working state ready for more commands? If so, consider doing that at the application level rather than trying to do it in SQL. All database interfaces give you a way to find out if an error occurred and get some information about the error.

Maybe if you explained your end goal and why you're trying to do this it might help people give you more useful answers?

--
Craig Ringer


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux