Re: JOIN Record returning Function

From: Tim Landscheidt <tim(at)tim-landscheidt(dot)de>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: JOIN Record returning Function
Date: 2010-02-03 22:07:22
Message-ID: m3iqaedld1.fsf@passepartout.tim-landscheidt.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Daniel Schuchardt <d(dot)schuchardt(at)prodat-sql(dot)de> wrote:

> i have a function that returns a record.

> myfunc(IN id INTEGER) RETURNS RECORD.

> in that function the record is build from some subquery's in
> dependence of data.

> Now i need to join that function to its correponding main
> table that holds the id.

> SELECT myfunc.* FROM maintable JOIN myfunc(maintable.pk) ON
> true WHERE maintable.field=statisticdata;

> ERROR: invalid reference to FROM-clause entry for table "maintable"
> TIP: There is an entry for table "maintable", but it cannot
> be referenced from this part of the query.

> so far so good, thats clear. But does anyone know a tricky
> solution for that problem?

"SELECT myfunc(pk) FROM maintable WHERE field =
statisticdata;"?

Tim

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2010-02-03 22:21:01 Re: PQendcopy:resetting connection Problem and Cannot insert a duplicate key into unique index
Previous Message Scott Marlowe 2010-02-03 21:26:14 Re: PQendcopy:resetting connection Problem and Cannot insert a duplicate key into unique index