Skip site navigation (1) Skip section navigation (2)

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

From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: "Nico Sabbi" <nsabbi(at)officinedigitali(dot)it>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: row->ARRAY or row->table casting?
Date: 2007-09-28 18:04:25
Message-ID: 87wsuavf86.fsf@oxford.xeocode.com (view raw or flat)
Thread:
Lists: pgsql-general
"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;

-- 
  Gregory Stark
  EnterpriseDB          http://www.enterprisedb.com

In response to

Responses

pgsql-general by date

Next:From: Sean DavisDate: 2007-09-28 18:11:13
Subject: Re: more problems with count(*) on large table
Previous:From: Gregory StarkDate: 2007-09-28 18:01:47
Subject: Re: more problems with count(*) on large table

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group