1

I firsted looked and followed tutorials for creating procedures in SQL. But when I tried to apply the syntax to pgadmin-4 it didn't work. I googled around and found out that in pgadmin-4 you can only create procedures in the "create procedure dialog". But I cant locate it. where do i find the "create procedure dialog" in Pg4? Or am I totally missinformed about the way to create procedures?

Thanks for any replies!

KarlPRO
  • 39
  • 8
  • 1
    You simply run `create procedure ....` or `create function ...` wherever you run SQL statements in pgAdmin. –  Jun 25 '20 at 13:06
  • But thats what i started with, I kept getting syntax error....... could please provide an example query of how that query ought to look like? I tried this: – KarlPRO Jun 25 '20 at 13:10
  • CREATE PROCEDURE dwd.spGet_Org as begin select counterparty_id, organisation_name from dwd_cpty_organizations end – KarlPRO Jun 25 '20 at 13:10
  • when writing that query im getting a red underscore under "procedure" and this error message :ERROR: syntax error at or near "PROCEDURE" LINE 1: CREATE PROCEDURE dwd.spGet_Org ^ SQL state: 42601 Character: 8 – KarlPRO Jun 25 '20 at 13:12
  • 1
    You cannot expect us to provide a tutorial on writing PostgreSQL functions... but [the documentation](https://www.postgresql.org/docs/current/plpgsql.html) should help you. – Laurenz Albe Jun 25 '20 at 13:13
  • Support for stored procedures was added in Postgres 11. Which version are you using? `select version();` will tell you. –  Jun 25 '20 at 13:14
  • For one, you need parentheses, even if there are no arguments. – Laurenz Albe Jun 25 '20 at 13:15
  • thats fair enough! – KarlPRO Jun 25 '20 at 13:15
  • i looked at a tutorial on youtube and simply followed his syntax. It worked for him, but he was on MySQL. So it seems as it differs between the two. Thanks for the guidance ill take it from here. – KarlPRO Jun 25 '20 at 13:17
  • "PostgreSQL 9.6.15 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.3 20140911 (Red Hat 4.8.3-9), 64-bit" – KarlPRO Jun 25 '20 at 13:18
  • ah in this version only create function exists. Thanks for the input a horse with no name! – KarlPRO Jun 25 '20 at 13:24

1 Answers1

1

TL;DR

Procedures are only available as of PostgreSQL 11.

pifor
  • 7,419
  • 2
  • 8
  • 16