Thread: Calling a function from another

Calling a function from another

From
Együd Csaba
Date:
Hi,
Could you please give me some help? I would like to call a function from
another. There are three functions, (say fa(int,int), fb(int,int) and
fc(int,int)). What's the problem with this:

create function "fc" (int, int) returns int as'
declare
  x alias for $1;
  y alias for $2;
begin
  perform fa (x,y);
  perform fb (x,y);
end;
' language 'plpgsql'

Or this:

create function "fc" (int, int) returns int as'
declare
  x alias for $1;
  y alias for $2;
begin
  execute ''select fa('' || x || '','' || y || '')'';
  execute ''select fb('' || x || '','' || y || '')'';
end;
' language 'plpgsql'

Or this:

create function "fc" (int, int) returns int as'
declare
  x alias for $1;
  y alias for $2;
begin
  execute ''select fa('' || quote_literal(x) || '','' || quote_literal(y) ||
'')'';
  execute ''select fb('' || quote_literal(x) || '','' || quote_literal(y) ||
'')'';
end;
' language 'plpgsql'


I tried all of them above. When I called them one after another from the
console, they worked proprely. But calling the composite function it did
nothing. No errors, just does not do anything.
How should I call these functions.

Thank you in advance,
Csaba




Re: Calling a function from another

From
Stephan Szabo
Date:
On Sat, 15 Feb 2003, [iso-8859-1] Egy�d Csaba wrote:

> Hi,
> Could you please give me some help? I would like to call a function from
> another. There are three functions, (say fa(int,int), fb(int,int) and
> fc(int,int)). What's the problem with this:
>
> create function "fc" (int, int) returns int as'
> declare
>   x alias for $1;
>   y alias for $2;
> begin
>   perform fa (x,y);
>   perform fb (x,y);
> end;
> ' language 'plpgsql'
>

> I tried all of them above. When I called them one after another from the
> console, they worked proprely. But calling the composite function it did
> nothing. No errors, just does not do anything.

All of those functions do have errors, but I'm not sure why you don't get
a message.  There's no return in any of them although that may be a cut
and paste error.  With a return, current sources at least seem to have the
above work (I made two functions with raise notice and both notices are
raised).  Can you make a complete example from scratch?