Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I call a PostgreSQL Function that returns VOID from PGAdmin?

I have a simple function defined in Postgresql defines as follows

CREATE OR REPLACE FUNCTION Foo(someid_param integer)
RETURNS void AS 
$$
BEGIN
    DELETE FROM SomeTable WHERE id = someid_param;
END;
$$ LANGUAGE plpgsql;

I've tried using EXEC, SELECT and PERFORM

PERFORM Foo(100);

But I get errors. What is the correct method for calling this function?

I'm using PGAdmin as my development environment.

like image 339
JohnB Avatar asked Nov 23 '25 06:11

JohnB


1 Answers

PERFORM belongs to PL/pgSQL, and EXEC isn't valid SQL. So, you can't use them. You should use

SELECT foo(100);

This should return a single line with an empty column named foo.

like image 91
clemens Avatar answered Nov 27 '25 16:11

clemens



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!