JohnB
JohnB

Reputation: 4359

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.

Upvotes: 3

Views: 6967

Answers (1)

clemens
clemens

Reputation: 17722

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.

Upvotes: 3

Related Questions