"Jasbinder Singh Bali" <jsbali(at)gmail(dot)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