how to call a stored function from another stored function? even possible?

Started by J.V.over 14 years ago3 messagesgeneral
Jump to latest
#1J.V.
jvsrvcs@gmail.com

I have a stored functionA that returns void

Inside there I have a line that says:
select functionB();

and it gives this error.

ERROR: query has no destination for result data
HINT: If you want to discard the results of a SELECT, use PERFORM instead.
CONTEXT: PL/pgSQL function "functionA" line 13 at SQL statement

********** Error **********

any ideas?

#2David G. Johnston
david.g.johnston@gmail.com
In reply to: J.V. (#1)
Re: how to call a stored function from another stored function? even possible?

On Oct 11, 2011, at 15:54, Java Services <jvsrvcs@gmail.com> wrote:

I have a stored functionA that returns void

Inside there I have a line that says:
select functionB();

and it gives this error.

ERROR: query has no destination for result data
HINT: If you want to discard the results of a SELECT, use PERFORM instead.
CONTEXT: PL/pgSQL function "functionA" line 13 at SQL statement

********** Error **********

any ideas?

If you want to discard the results of a SELECT, use PERFORM instead.

See 39.5.2

David J.

In reply to: J.V. (#1)
Re: how to call a stored function from another stored function? even possible?

On 11/10/2011 20:54, Java Services wrote:

I have a stored functionA that returns void

Inside there I have a line that says:
select functionB();

and it gives this error.

ERROR: query has no destination for result data
HINT: If you want to discard the results of a SELECT, use PERFORM instead.
CONTEXT: PL/pgSQL function "functionA" line 13 at SQL statement

As the message says, in pl/pgsql you need to specify a destination for
the returned data:

create or replace function....
as
$$
declare
my_value ....
begin
select function_b() into my_value;
(etc)

If you don't need the return value of function_b(), or if it returns
void, then use PERFORM instead:

perform function_b();

Gory details here:

www.postgresql.org/docs/9.1/static/plpgsql-statements.html

HTH

Ray.

--
Raymond O'Donnell :: Galway :: Ireland
rod@iol.ie