Re: Throwing exceptions

From: Michael Glaesemann <grzm(at)seespotcode(dot)net>
To: Germán Hüttemann Arza <ghuttemann(at)cnc(dot)una(dot)py>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Throwing exceptions
Date: 2007-06-26 00:01:18
Message-ID: 3A90E3C9-8C29-4D5D-B7A2-15A1EB5F0D54@seespotcode.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Jun 21, 2007, at 10:30 , Germán Hüttemann Arza wrote:

> I need a way to throw a message in a function, when an exception
> occurs, but I
> don't want to write again and again the same message in every place
> I need to
> throw it. So, is there a way to handle this situation in a more
> general
> manner?

The message is just a string. Assign the message to a variable and
use the variable in place of the message. For example, in PL/pgSQL:

k_error_message := 'Boom! %';
RAISE EXCEPTION k_error_message, v_foo.id;

Hope that helps.

Michael Glaesemann
grzm seespotcode net

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Michael Glaesemann 2007-06-26 00:08:25 Re: pg_dump to include multiple tables
Previous Message Tom Lane 2007-06-25 22:37:59 Re: Error or bug?