Re: Capturing return value of a function - Mailing list pgsql-general

From Gregory Stark
Subject Re: Capturing return value of a function
Date
Msg-id 87d4ysvya0.fsf@oxford.xeocode.com
Whole thread Raw
In response to Capturing return value of a function  ("Jasbinder Singh Bali" <jsbali@gmail.com>)
List pgsql-general
"Jasbinder Singh Bali" <jsbali@gmail.com> writes:

> I was wondering what would the function return if insert fails.

It would abort immediately and abort your transaction as well unless something
higher up catches the error.

> I want it to return 'success'  upon a successful insert and 'failure' if
> insert fails.

You need an EXCEPT WHEN clause, see:

http://www.postgresql.org/docs/8.2/interactive/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING


--
  Gregory Stark
  EnterpriseDB          http://www.enterprisedb.com


pgsql-general by date:

Previous
From: Michael Glaesemann
Date:
Subject: Re: Capturing return value of a function
Next
From: Alvaro Herrera
Date:
Subject: Re: Moved postgres, now won't start