It's not the first time I get this strange NOTICE when adding perl functions in Postgresql :
NOTICE: elseif should be elsif at line 11.
This happens at CREATE FUNCTION as well as when using the function.
Of course I tried to change with elsif but then it fails with syntax error.
Any advice would be appreciated (even if I can cope with that NOTICE)
This is my code:
CREATE FUNCTION hds_updatewebservers_products(character varying)
RETURNS boolean
AS
$_$
my $product_ref = @_[0];
# Launch update
$checkexitcode = system ("sudo -u dbliveud /home/dbliveud/scripts/maj/launch-all.sh " . $product_ref . " ");
if ($checkexitcode > 0) {
# Error while updating
return false;
} elseif {
# Ok update done
return true;
}
$_$
LANGUAGE plperlu STRICT;
Best Answer
I can't reproduce your error, it works fine on my PostgreSQL 9.5 on Linux. What version and platform are you running?
Note that your function can be exploited really badly, e.g.
Why are you using
elseif
? Why not justelse
? See perl's documentation onelseif
Finally, you can simply (and elegantly):