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

Started by Andre Lopesalmost 16 years ago3 messagesgeneral
Jump to latest
#1Andre Lopes
lopes80andre@gmail.com

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,

#2Adrian Klaver
adrian.klaver@aklaver.com
In reply to: Andre Lopes (#1)
Re: How to exit/abort from a function that returns VOID?

On Tuesday 04 May 2010 1:55:35 pm Andre Lopes wrote:

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,

RETURN;
From here:
http://www.postgresql.org/docs/8.4/interactive/plpgsql-control-structures.html#PLPGSQL-STATEMENTS-RETURNING

--
Adrian Klaver
adrian.klaver@gmail.com

#3Andre Lopes
lopes80andre@gmail.com
In reply to: Adrian Klaver (#2)
Re: How to exit/abort from a function that returns VOID?

Thanks. I got working.

Best Regards,

On Tue, May 4, 2010 at 10:25 PM, Adrian Klaver <adrian.klaver@gmail.com>wrote:

Show quoted text

On Tuesday 04 May 2010 1:55:35 pm Andre Lopes wrote:

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,

RETURN;
From here:

http://www.postgresql.org/docs/8.4/interactive/plpgsql-control-structures.html#PLPGSQL-STATEMENTS-RETURNING

--
Adrian Klaver
adrian.klaver@gmail.com