Thanks for all the comments.
Do I need to use BEGIN/COMMIT in my plpgsql-function for UPSERT or arefunctions atomic?
RegardsAlex