Re: rollback in C functions - Mailing list pgsql-general

From Juan Pablo L
Subject Re: rollback in C functions
Date
Msg-id CABSYDaZt+FLhkc1XN-ZnSKJ2-XqrHaBft1jCMRvKR+DVXmGUPA@mail.gmail.com
Whole thread Raw
In response to Re: rollback in C functions  (Chris Mair <chris@1006.org>)
List pgsql-general
Hi Thanks Chris, yes i have already tested ereport and even made up my own sql state to report and error but from the application i can not access this error code directly (through the PQexec,PQresultErrorField,etc functions because the PGresult returns NULL) but i have to register a callback function that will be called with this error code with the idea to format the error message so i could intercept this and do something, but this does not allow me to have direct access to the flow where this is all happening .. i hope it is clear ...

On 19 February 2015 at 15:02, Chris Mair <chris@1006.org> wrote:
> The function is to execute updates on each ID assigning the value, but if
> one of these operation fails (does not meet certain criteria)
> inside the function i would like to rollback and leave everything
> untouched, in case other ID;s were already updated previously,
> and come back to the caller and infor

Hi,

I think you want ereport(), here is an example:
http://www.postgresql.org/docs/9.3/static/xfunc-c.html

Bye,
Chris.



pgsql-general by date:

Previous
From: Chris Mair
Date:
Subject: Re: rollback in C functions
Next
From: Alban Hertroys
Date:
Subject: Re: select where true, or select where input = '$var'