Re: row->ARRAY or row->table casting?

From: Nico Sabbi <nsabbi(at)officinedigitali(dot)it>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: row->ARRAY or row->table casting?
Date: 2007-10-01 16:34:59
Message-ID: 470121B3.7060706@officinedigitali.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Gregory Stark ha scritto:
> "Nico Sabbi" <nsabbi(at)officinedigitali(dot)it> writes:
>
>
>> nb1=# select r.a from (select row(tab1.*)::tab1 as r from tab1)x;
>> ERROR: missing FROM-clause entry for table "r"
>> LINE 1: select r.a from (select row(tab1.*)::tab1 as r from tab1)x;
>> ^
>> I tried many variations (including casting x as tab1) obtaining only syntax
>> errors.
>>
>
> r.a would be the column "a" in the table named "r", but the only table in the
> FROM list is "x". So you have to use a workaround to make it clear to the
> parser that you're referring to the column "r", it would look like
>
> SELECT (r).a from (select row(tab1.*)::tab1 as r from tab1)x;
>
>
yes, it works.

Thanks a lot,
Nico

In response to

Browse pgsql-general by date

  From Date Subject
Next Message joynes 2007-10-01 16:56:28 Find out encoding of data
Previous Message Alvaro Herrera 2007-10-01 16:33:35 Re: Inheritance fixing timeline? (Was "Inherited FK Indexing")