How to exit/abort from a function that returns VOID?

From: Andre Lopes <lopes80andre(at)gmail(dot)com>
To: postgresql Forums <pgsql-general(at)postgresql(dot)org>
Subject: How to exit/abort from a function that returns VOID?
Date: 2010-05-04 20:55:35
Message-ID: u2t18f98e681005041355h44a0707dq1a769284a0572916@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

HI,

I have a PLPgSQL function that return void but I need to exit the function
if some condition returns true.

I have tried to do this, but I got an error:

[code]
IF pVAL_CHAVE_2 > pVAL_CAMPO1 THEN
RAISE NOTICE 'O campo data fim tem de ser maior que o campo data
inicio.';
RETURN 0;
END IF;
[/code]

The error is the folowing:

[quote]
ERROR: RETURN cannot have a parameter in function returning void at or near
"0" at character 1973
[/quote]

My question. How can I display the NOTICE and exit the function?

Best Regards,

Responses

Browse pgsql-general by date

  From Date Subject
Next Message pgsql 2010-05-04 21:05:46 Please help me debug regular segfaults on 8.3.10
Previous Message Tom Lane 2010-05-04 20:35:36 Re: why there are two TargetEntrys in Query when i use "select count(catcode) from pois group by catcode"?