in reply to Re: plperl (postgreSQL perl) get url function
in thread plperl (postgreSQL perl) get url function

Thanks Rolf, though it does not work for me. I tried
use LWP::Simple;
but then I can't even compile my function, it returns error:
ERROR: Unable to load LWP/Simple.pm into plperl at line 4. BEGIN failed--compilation aborted at line 4. CONTEXT: compilation of PL/Perl function "get"
Please advise.

Replies are listed 'Best First'.
Re^3: plperl (postgreSQL perl) get url function
by poj (Abbot) on May 28, 2019 at 12:45 UTC

    see Trusted and Untrusted PL/Perl

    I was able to get this to work using plperlu after running CREATE EXTENSION plperlu;

    CREATE OR REPLACE FUNCTION get(character varying) RETURNS json AS $BODY$ use warnings; use strict; use LWP::Simple; my $content = get($_[0]); $content =~ s/ /%20/g; return $content; $BODY$ LANGUAGE plperlu VOLATILE COST 100;
    poj
Re^3: plperl (postgreSQL perl) get url function
by LanX (Saint) on May 27, 2019 at 22:37 UTC
    > ERROR: Unable to load LWP/Simple.pm into plperl at line 4.

    • make sure that LWP::Simple is available on that server
    • elaborate this libs path
    • try warn "@INC"; to see if it's already included
    • otherwise add use lib "PATH"; before trying to load LWP::Simple

    see lib for details

    I've never worked with such postgres exetensions, probably they have been deliberately disabled by your server's admin.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

      Looks like plperl extension does not allow all this stuff like LWP::Simple. Though plperlu (perl unrestricted) extension would allow it, but it is not available in Amazon RDS. Thanks for help anyway.