views:

82

answers:

1
CREATE FUNCTION foo() RETURNS text
    LANGUAGE plperl
    AS $$
        return 'foo';
$$;

CREATE FUNCTION foobar() RETURNS text
    LANGUAGE plperl
    AS $$
        return foo() . 'bar';
$$;

I'm trying to compose results using multiple functions, but when I call foobar() I get an empty result.

+4  A: 

From the documentation:

PL/Perl functions cannot call each other directly (because they are anonymous subroutines inside Perl).

The solution appears to be either calling the function as a postgres function (using spi_query) or you can put references to your functions in the globally available hash %_SHARED as shown here

MadCoder