Home > Archive > PostgreSQL JDBC > December 2005 > Group Query









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Group Query
Rob Kirkbride

2005-12-14, 7:24 am

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,

Rob


---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Achilleus Mantzios

2005-12-14, 7:24 am

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(se
lect groname from pg_group where ?=any(grolist));
st.setInt(1,uid);

maybe?
>
> Rob
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster
>


--
-Achilleus


---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Rob Kirkbride

2005-12-14, 7:24 am

Achilleus Mantzios wrote:

>O Rob Kirkbride έγραψε στις Dec 14, 2005 :
>
>
>
>
>st=con. preparedStatement(se
lect 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(gro
list, '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


---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com