Can't use WITH in a PERFORM query in PL/pgSQL?

From: <depstein(at)alliedtesting(dot)com>
To: <pgsql-bugs(at)postgresql(dot)org>
Cc: <pgagarinov(at)alliedtesting(dot)com>, <vshahov(at)alliedtesting(dot)com>
Subject: Can't use WITH in a PERFORM query in PL/pgSQL?
Date: 2011-03-06 13:29:28
Message-ID: 29F36C7C98AB09499B1A209D48EAA615B501DA902C@mail2a.alliedtesting.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

PostgreSQL 9.0.1

It seems that PostgreSQL doesn't understand the WITH construct when used in a PERFORM query inside PL/pgSQL functions and code blocks:

Example:

do
$$begin
with A as (select 1 as foo)
perform foo from A;
end$$;

syntax error at or near "perform"

do
$$begin
with A as (select 1 as foo)
select foo from A;
end$$;

query has no destination for result data

The only workaround that I can think of is to use a dummy variable to capture the query result. This has to be done even when the query doesn't have a result (as when calling a function returning void).

do
$$declare
dummy record;
begin
with A as (select 1 as foo)
select foo into dummy from A;
end$$;

Dmitry Epstein | Developer
Allied Testing
T + 7 495 544 48 69 Ext 417
M + 7 926 215 73 36

www.alliedtesting.com<http://www.alliedtesting.com/>
We Deliver Quality.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Vik Reykja 2011-03-06 14:57:53 Re: Can't use WITH in a PERFORM query in PL/pgSQL?
Previous Message Heikki Linnakangas 2011-03-05 21:18:19 Re: BUG #5915: OldSerXidAdd inflates pg_serial too much