BEGIN EXCEPTION END - small bug? - Mailing list pgsql-hackers

From Daniel Schuchardt
Subject BEGIN EXCEPTION END - small bug?
Date
Msg-id cfd2uf$21qq$1@news.hub.org
Whole thread Raw
Responses Re: BEGIN EXCEPTION END - small bug?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Hi list,

i tried a bit with errorhandling and found the following :
(i want to ignore the dublicate key exception)


CREATE OR REPLACE FUNCTION test() RETURNS VARCHAR AS'
BEGIN BEGIN  INSERT INTO table a dublicate key (primary); EXCEPTION  WHEN OTHERS THEN ROLLBACK; END; RETURN ''test'';
END'LANGUAGE plpgsql;


will result in

ERROR:  SPI_prepare failed for "ROLLBACK": SPI_ERROR_TRANSACTION

I noticed the right syntax would be (works fine)

CREATE OR REPLACE FUNCTION test() RETURNS VARCHAR AS'
BEGIN BEGIN  INSERT INTO table a dublicate key (primary); EXCEPTION  WHEN OTHERS THEN END; RETURN ''test'';
END'LANGUAGE plpgsql;


Just a hint

Regards Daniel


pgsql-hackers by date:

Previous
From: Christopher Browne
Date:
Subject: Re: Postgres development model
Next
From: "Jonah H. Harris"
Date:
Subject: Re: Ready for Beta ... ?