Re: [GENERAL] join between a table and function.

2011-08-17 Thread Lauri Kajan
Thanks for every one for help. I got it to work. The reason i used a function is that it calculates the values/attributes from several tables in a pretty complex way. I tried to do this by a view first but couldn't do it. I think it's impossible. The function is always supposed to return only one

Re: [GENERAL] join between a table and function.

2011-08-16 Thread David Johnston
On Aug 16, 2011, at 14:29, Merlin Moncure wrote: > On Tue, Aug 16, 2011 at 8:33 AM, Harald Fuchs wrote: >> In article >> , >> Lauri Kajan writes: >> >>> I have also tried: >>> select >>> *, getAttributes(a.id) >>> from >>> myTable a >> >>> That works almost. I'll get all the fields from my

Re: [GENERAL] join between a table and function.

2011-08-16 Thread Merlin Moncure
On Tue, Aug 16, 2011 at 8:33 AM, Harald Fuchs wrote: > In article > , > Lauri Kajan writes: > >> I have also tried: >> select >> *, getAttributes(a.id) >> from >>   myTable a > >> That works almost. I'll get all the fields from myTable, but only a >> one field from my function type of attributes

Re: [GENERAL] join between a table and function.

2011-08-16 Thread David Johnston
gresql.org] On Behalf Of Lauri Kajan Sent: Tuesday, August 16, 2011 9:04 AM To: pgsql-general@postgresql.org Subject: Re: [GENERAL] join between a table and function. Hi Chetan, I checked out your link but still can't figure it out. How could I pass the parameter to the function from another tabl

Re: [GENERAL] join between a table and function.

2011-08-16 Thread Harald Fuchs
In article , Lauri Kajan writes: > I have also tried: > select > *, getAttributes(a.id) > from > myTable a > That works almost. I'll get all the fields from myTable, but only a > one field from my function type of attributes. > myTable.id | myTable.name | getAttributes > integer | charact

Re: [GENERAL] join between a table and function.

2011-08-16 Thread Lauri Kajan
Hi Chetan, I checked out your link but still can't figure it out. How could I pass the parameter to the function from another table. If I try to join or select from the function I'll get an error told that I cannot refer to other relations of same query level. -Lauri On Tue, Aug 16, 2011 at 1

Re: [GENERAL] join between a table and function.

2011-08-16 Thread Chetan Suttraway
On Tue, Aug 16, 2011 at 1:11 PM, Lauri Kajan wrote: > Hi all, > > I have made a function returning a custom record type that contains two > fields. > Now I want to select from that function. Actually I want to make a > join with a table. > > Let me explain. > > Here is my function: > CREATE TYPE

[GENERAL] join between a table and function.

2011-08-16 Thread Lauri Kajan
Hi all, I have made a function returning a custom record type that contains two fields. Now I want to select from that function. Actually I want to make a join with a table. Let me explain. Here is my function: CREATE TYPE attributes AS (class integer, type integer); CREATE OR REPLACE FUNCTION g