pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #16181: Error Creating Stored Procedures
3+ messages / 3 participants
[nested] [flat]
* BUG #16181: Error Creating Stored Procedures
@ 2020-01-01 23:42 PG Bug reporting form <noreply@postgresql.org>
0 siblings, 1 reply; 3+ messages in thread
From: PG Bug reporting form @ 2020-01-01 23:42 UTC (permalink / raw)
To: pgsql-bugs@lists.postgresql.org; +Cc: shahzadahmad00@gmail.com
The following bug has been logged on the website:
Bug reference: 16181
Logged by: Shahzad Ahmad
Email address: shahzadahmad00@gmail.com
PostgreSQL version: 12.1
Operating system: Ubuntu 18.04.3 LTS
Description:
I tried both pgAdmin GUI and psql using a script file. In both instances i
got the same error.
CREATE OR REPLACE PROCEDURE admin.my_test(IN role_id integer DEFAULT 0)
LANGUAGE 'plpgsql'
AS $BODY$
IF my_test.user_id = 0 THEN
Select *
from admin.roles
order by role_name;
ELSE
Select *
from admin.roles
WHERE role_id = my_test.user_id
order by role_name;
END IF;
$BODY$;
ERROR: syntax error at or near "IF"
LINE 5: IF my_test.user_id = 0 THEN
^
SQL state: 42601
Character: 103
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: BUG #16181: Error Creating Stored Procedures
@ 2020-01-02 00:01 David G. Johnston <david.g.johnston@gmail.com>
parent: PG Bug reporting form <noreply@postgresql.org>
0 siblings, 1 reply; 3+ messages in thread
From: David G. Johnston @ 2020-01-02 00:01 UTC (permalink / raw)
To: shahzadahmad00@gmail.com, PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
On Wed, Jan 1, 2020 at 4:43 PM PG Bug reporting form <noreply@postgresql.org>
wrote:
> The following bug has been logged on the website:
>
> Bug reference: 16181
> Logged by: Shahzad Ahmad
> Email address: shahzadahmad00@gmail.com
> PostgreSQL version: 12.1
> Operating system: Ubuntu 18.04.3 LTS
> Description:
>
> I tried both pgAdmin GUI and psql using a script file. In both instances i
> got the same error.
>
> CREATE OR REPLACE PROCEDURE admin.my_test(IN role_id integer DEFAULT 0)
> LANGUAGE 'plpgsql'
>
Not a bug...the documentation shows how to write a pl/pgsql function/stored
procedure.
https://www.postgresql.org/docs/12/plpgsql-structure.html
Note the "BEGIN" and "END" portions of that syntax diagram are not optional.
David J.
^ permalink raw reply [nested|flat] 3+ messages in thread
* RE: BUG #16181: Error Creating Stored Procedures
@ 2020-01-02 00:18 Shahzad Ahmad <shahzadahmad00@gmail.com>
parent: David G. Johnston <david.g.johnston@gmail.com>
0 siblings, 0 replies; 3+ messages in thread
From: Shahzad Ahmad @ 2020-01-02 00:18 UTC (permalink / raw)
To: 'David G. Johnston' <david.g.johnston@gmail.com>; 'PostgreSQL mailing lists' <pgsql-bugs@lists.postgresql.org>
David,
Thanks for the quick reply.
It is working with BEGIN and END.
The code was generated by pgAdmin4 GUI and I somehow incorrectly assumed that GUI would include BEGIN and END statements.
Thanks for your help.
Shahzad
From: David G. Johnston <david.g.johnston@gmail.com>
Sent: Wednesday, January 1, 2020 7:02 PM
To: shahzadahmad00@gmail.com; PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Subject: Re: BUG #16181: Error Creating Stored Procedures
On Wed, Jan 1, 2020 at 4:43 PM PG Bug reporting form <noreply@postgresql.org <mailto:noreply@postgresql.org> > wrote:
The following bug has been logged on the website:
Bug reference: 16181
Logged by: Shahzad Ahmad
Email address: shahzadahmad00@gmail.com <mailto:shahzadahmad00@gmail.com>
PostgreSQL version: 12.1
Operating system: Ubuntu 18.04.3 LTS
Description:
I tried both pgAdmin GUI and psql using a script file. In both instances i
got the same error.
CREATE OR REPLACE PROCEDURE admin.my_test(IN role_id integer DEFAULT 0)
LANGUAGE 'plpgsql'
Not a bug...the documentation shows how to write a pl/pgsql function/stored procedure.
https://www.postgresql.org/docs/12/plpgsql-structure.html
Note the "BEGIN" and "END" portions of that syntax diagram are not optional.
David J.
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2020-01-02 00:18 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-01-01 23:42 BUG #16181: Error Creating Stored Procedures PG Bug reporting form <noreply@postgresql.org>
2020-01-02 00:01 ` David G. Johnston <david.g.johnston@gmail.com>
2020-01-02 00:18 ` Shahzad Ahmad <shahzadahmad00@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox