Thread: usernames of a group from SQL
Hi, At the first time: I'm in newbie in SQL... I'm sorry! My question is: How can I get the usernames of a group (for example 'osztatlan_users') from SQL? I try it: SELECT usename FROM pg_user WHERE usesysid IN (SELECT grolist FROM pg_group WHERE groname='osztatlan_users') ORDER BY pg_user; But I get the next error message: ERROR: operator does not exist: oid = oid[] HINT: No operator matches the given name and argument type(s). You may need to add explicit type casts. I see, what is the problem, but what can I do...? Thans, kjt McAfee SCM 4.1 által ellenőrizve!
O Kis Jαnos Tamαs έγραψε στις May 19, 2006 : > Hi, > > At the first time: I'm in newbie in SQL... I'm sorry! > > My question is: How can I get the usernames of a group (for example > 'osztatlan_users') from SQL? > > I try it: > > SELECT usename > FROM pg_user > WHERE usesysid IN (SELECT grolist FROM pg_group WHERE > groname='osztatlan_users') > ORDER BY pg_user; > > But I get the next error message: > > ERROR: operator does not exist: oid = oid[] > HINT: No operator matches the given name and argument type(s). You > may need to add explicit type casts. > > I see, what is the problem, but what can I do...? SELECT u.usename from pg_user u,pg_group g where u.usesysid = any (g.grolist) and g.groname='osztatlan_users'; > > Thans, > kjt > > > McAfee SCM 4.1 αltal ellenυrizve! > > ---------------------------(end of broadcast)---------------------------TIP 4: Have you searched our list archives? > http://archives.postgresql.org > -- -Achilleus
On Friday May 19 2006 12.04, Achilleus Mantzios wrote: > > SELECT u.usename from pg_user u,pg_group g where u.usesysid = any > (g.grolist) and g.groname='osztatlan_users'; > I'd like to make a function with this SQL: CREATE FUNCTION kodok.group_users(group_name "varchar") RETURNS SETOF "varchar" AS $BODY$ SELECT pg_user.usename FROM pg_user, pg_group WHERE usesysid = any (pg_group.grolist) AND pg_group.groname=$1; $BODY$ LANGUAGE 'sql' VOLATILE; But I get the next error message: ERROR: return type mismatch in function declared to return character varying DETAIL: Actual return type is name. CONTEXT: SQL function "group_users" At the moment, I don't understand what is the problem, and what I need to do now...? Thanks, kjt ____________________________________________________________________ Nagyobb szabadsαgra vαgysz? Tφrj ki a nιgy fal kφzόl! Start ADSL elυfizetιsedhez az EuroWeb mostantσl havi 100 perc ingyenes WiFi hozzαfιrιst biztosνt szαmodra. Rιszletek: www.freestart.hu
Hi, Kijato, kijato schrieb: > CREATE FUNCTION kodok.group_users(group_name "varchar") > RETURNS SETOF "varchar" AS > $BODY$ > SELECT pg_user.usename > FROM pg_user, pg_group > WHERE usesysid = any (pg_group.grolist) AND pg_group.groname=$1; > $BODY$ > LANGUAGE 'sql' VOLATILE; The pg_user.username column uses the PostgreSQL internal type "name" which is used for identifiers like table and user names. The PostgreSQL Documentation contains more about this. I think you can cast it to varchar, like: SELECT pg_user.username::varchar HTH, Markus