0

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 enter image description here

What is done wrong? Not sure how I check version of postgresql itself

0

2 Answers 2

4

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);
$$;
Sign up to request clarification or add additional context in comments.

Comments

1

According to PostgreSQL documentation, syntax is supported in versions 11 and 12.

PostgreSQL: Documentation: 11: CREATE PROCEDURE

DocumentationPostgreSQL 11

Supported Versions: Current (11)

Development Versions: 12 / devel

Check PostgreSQL version on your server, run this query from PgAdmin:

SELECT version();

2 Comments

thanks, it is "PostgreSQL 10.7 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.9.3, 64-bit" there is no way I create procedure for it?
@pwrigshihanomoronimo: use a function then

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.