3

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.

2
  • "But I get errors." can you add the error you are getting? Would help Commented Apr 20, 2018 at 4:15
  • ERROR: syntax error at or near "PERFORM" LINE 1: PERFORM Foo(122) Commented Apr 20, 2018 at 4:22

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.