join against a function-result fails

From: Andreas <maps(dot)on(at)gmx(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Subject: join against a function-result fails
Date: 2012-07-28 01:57:00
Message-ID: 501346EC.2000305@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi,
I have a table with user ids and names.
Another table describes some rights of those users and still another one
describes who inherits rights from who.

A function all_rights ( user_id ) calculates all rights of a user
recursively and gives back a table with all userright_ids this user
directly has or inherits of other users as ( user_id, userright_id ).

Now I'd like to find all users who have the right 42.

select user_id, user_name
from users
join all_rights ( user_id ) using ( user_id )
where userright_id = 42;

won't work because the parameter user_id for the function all_rights()
is unknown when the function gets called.

Is there a way to do this?

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message David Johnston 2012-07-28 02:31:46 Re: join against a function-result fails
Previous Message Russell Keane 2012-07-27 10:33:07 Re: FW: view derived from view doesn't use indexes