pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andreas <maps.on@gmx.net>
To: pgsql-sql@postgresql.org
Subject: join against a function-result fails
Date: Sat, 28 Jul 2012 03:57:00 +0200
Message-ID: <501346EC.2000305@gmx.net> (raw)

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?



view thread (2+ messages)  latest in thread

Message-ID: <501346EC.2000305@gmx.net>
Permalink:  ../501346EC.2000305@gmx.net/
Also on:    postgresql.org/message-id/501346EC.2000305@gmx.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: maps.on@gmx.net
  Subject: Re: join against a function-result fails
  In-Reply-To: <501346EC.2000305@gmx.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox