pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rob Kirkbride <rob@rkcomputing.co.uk>
To: Achilleus Mantzios <achill@matrix.gatewaynet.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Group Query
Date: Wed, 14 Dec 2005 12:57:31 +0000
Message-ID: <43A016BB.6030605@rkcomputing.co.uk> (raw)
In-Reply-To: <Pine.LNX.4.44.0512141541050.16112-100000@matrix.gatewaynet.com>
References: <Pine.LNX.4.44.0512141541050.16112-100000@matrix.gatewaynet.com>

Achilleus Mantzios wrote:

>O Rob Kirkbride Ýãñáøå óôéò Dec 14, 2005 :
>
>  
>
>>Hi,
>>
>>It's probably because I'm struggling with array queries but how can I 
>>get the (textual) list of groups allocated to the current user?
>>
>>I can get the current_user and extract the id out of pg_user, however I 
>>need to then match this to an element as part of a list in pg_group, 
>>this is the part I can't find how how to do. I'd like it as a ResultSet 
>>with each element with the textual group name
>>
>>Thanks for any help,
>>    
>>
>
>st=con.preparedStatement(select groname from pg_group where ?=any(grolist));
>st.setInt(1,uid);
>
>maybe?
>  
>
Thanks thats better than my :-
select groname from pg_group where (array_to_string(grolist, 'x') || 
'x') like '%' || (select usesysid from pg_user where 
usename=current_user) || 'x%'

I wasn't aware of the any operator!

Thanks a lot!

Rob




view thread (3+ messages)  latest in thread

Message-ID: <43A016BB.6030605@rkcomputing.co.uk>
Permalink:  ../43A016BB.6030605@rkcomputing.co.uk/
Also on:    postgresql.org/message-id/43A016BB.6030605@rkcomputing.co.uk

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: rob@rkcomputing.co.uk, achill@matrix.gatewaynet.com
  Subject: Re: Group Query
  In-Reply-To: <43A016BB.6030605@rkcomputing.co.uk>
  References: <Pine.LNX.4.44.0512141541050.16112-100000@matrix.gatewaynet.com> <43A016BB.6030605@rkcomputing.co.uk>

* 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