Re: Why won't nested select-into expression work?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Leon Starr <leon_starr(at)modelint(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Why won't nested select-into expression work?
Date: 2010-11-23 19:38:39
Message-ID: 14327.1290541119@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Leon Starr <leon_starr(at)modelint(dot)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

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Leon Starr 2010-11-23 19:46:29 Re: Why won't nested select-into expression work?
Previous Message Leon Starr 2010-11-23 19:24:40 Why won't nested select-into expression work?