Unix Technical Forum

EXCEPTION in pl/pgsql

This is a discussion on EXCEPTION in pl/pgsql within the Pgsql General forums, part of the PostgreSQL category; --> Hi All What is the syntax if I want to use the exception clause in a pl/pgsql function, but ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql General

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-09-2008, 05:02 AM
Craig Bryden
 
Posts: n/a
Default EXCEPTION in pl/pgsql

Hi All

What is the syntax if I want to use the exception clause in a pl/pgsql
function, but am not looking for a particular error. Kind of like a "any
error" type thing.

some thing like:

CREATE OR REPLACE FUNCTION func1(p_Param1 int4)
RETURNS int4
AS
$$


DECLARE
v_Var1 int4;

BEGIN
[Statements]
RETURN 1;

EXCEPTION
WHEN <any_error> THEN
ROLLBACK;
RETURN -1;
END;
$$ LANGUAGE 'plpgsql' volatile;



What should I replace <any_error> with?

Thanks


---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-09-2008, 05:02 AM
Hannes Dorbath
 
Posts: n/a
Default Re: EXCEPTION in pl/pgsql

On 19.07.2005 20:56, Craig Bryden wrote:
> What is the syntax if I want to use the exception clause in a pl/pgsql
> function, but am not looking for a particular error. Kind of like a "any
> error" type thing.
>


35.7.5. Trapping Errors
http://www.postgresql.org/docs/8.0/i...ERROR-TRAPPING

"The special condition name OTHERS matches every error type except
QUERY_CANCELED."
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 12:36 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com