Re: PL/pgSQL PERFORM with CTE - Mailing list pgsql-hackers

From David E. Wheeler
Subject Re: PL/pgSQL PERFORM with CTE
Date
Msg-id EA4D28FD-FE4B-4643-A6DC-F8D93C99C4FA@justatheory.com
Whole thread Raw
In response to Re: PL/pgSQL PERFORM with CTE  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: PL/pgSQL PERFORM with CTE  (Pavel Stehule <pavel.stehule@gmail.com>)
Re: PL/pgSQL PERFORM with CTE  (Boszormenyi Zoltan <zb@cybertec.at>)
List pgsql-hackers
On Aug 20, 2013, at 2:31 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote:

> but it works
>
> postgres=# do $$begin with x as (select 10) insert into omega select * from x; end;$$;
> DO

But this does not:

david=# DO $$
david$# BEGIN
david$#     PERFORM * FROM (
david$#         WITH inserted AS (
david$#             INSERT INTO foo values (1) RETURNING id
david$#         ) SELECT inserted.id
david$#     ) x;
david$# END;
david$# $$;
ERROR:  WITH clause containing a data-modifying statement must be at the top level
LINE 2:         WITH inserted AS (                    ^
QUERY:  SELECT * FROM (       WITH inserted AS (           INSERT INTO foo values (1) RETURNING id       ) SELECT
inserted.id  ) x 
CONTEXT:  PL/pgSQL function inline_code_block line 3 at PERFORM

Best,

David




pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: PL/pgSQL PERFORM with CTE
Next
From: Pavel Stehule
Date:
Subject: Re: PL/pgSQL PERFORM with CTE