Re: Why won't nested select-into expression work? - Mailing list pgsql-novice

From Leon Starr
Subject Re: Why won't nested select-into expression work?
Date
Msg-id A203B6DC-013F-4E84-80B1-18C199B32BB0@modelint.com
Whole thread Raw
In response to Re: Why won't nested select-into expression work?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-novice
Good to know the rule.  Not entirely clear on why it's a feature and not a bug, but
that's why I posted as a novice!

On Nov 23, 2010, at 11:38 AM, Tom Lane wrote:

> Leon Starr <leon_starr@modelint.com> writes:
>> I tried this and it failed (see embedded comments):
>
>>         select * into my_paragraph from paragraph where
>>             form = p_form and
>>             number = ( select method_paragraph_new( p_form, 0, p_append ) );
>>             -- Inner expression above inserts a new row in the 'paragraph' table which
>>             -- just happens to be the one I want selected by the outer select-into expression
>
> You're apparently expecting that the row inserted by
> method_paragraph_new() will be seen by the already-in-progress outer
> query?  That won't happen.  A SELECT will only see rows that exist
> when it starts execution.  This is a feature, not a bug.
>
>             regards, tom lane
>
> --
> Sent via pgsql-novice mailing list (pgsql-novice@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-novice



pgsql-novice by date:

Previous
From: Leon Starr
Date:
Subject: Why won't nested select-into expression work?
Next
From: "Rob Richardson"
Date:
Subject: Why won't this function loop?