Reputation: 6152
My database is hosted in Amazon and I am using pgAdmin 4 to connect to it. I copy-pasted snippet from https://www.postgresql.org/docs/11/sql-createprocedure.html
CREATE PROCEDURE insert_data(a integer, b integer)
LANGUAGE SQL
AS $$
INSERT INTO tbl VALUES (a);
INSERT INTO tbl VALUES (b);
$$;
The issue is that I get 'incorrect syntax near 'PROCEDURE' ' error
What is done wrong? Not sure how I check version of postgresql itself
Upvotes: 0
Views: 2558
Reputation:
With Postgres 10, you need to use a function:
CREATE function insert_data(a integer, b integer)
returns void
LANGUAGE SQL
AS $$
INSERT INTO tbl VALUES (a), (b);
$$;
Upvotes: 4
Reputation: 4476
According to PostgreSQL documentation, syntax is supported in versions 11 and 12.
PostgreSQL: Documentation: 11: CREATE PROCEDURE
Check PostgreSQL version on your server, run this query from PgAdmin:
SELECT version();
Upvotes: 1