pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
usernames of a group from SQL
4+ messages / 4 participants
[nested] [flat]

* usernames of a group from SQL
@ 2006-05-19 08:40  Kis <kjt@takarnet.hu>
  0 siblings, 1 reply; 4+ messages in thread

From: Kis János Tamás @ 2006-05-19 08:40 UTC (permalink / raw)
  To: pgsql-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!


^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: usernames of a group from SQL
@ 2006-05-19 10:04  Achilleus Mantzios <achill@matrix.gatewaynet.com>
  parent: Kis <kjt@takarnet.hu>
  0 siblings, 1 reply; 4+ messages in thread

From: Achilleus Mantzios @ 2006-05-19 10:04 UTC (permalink / raw)
  To: Kis János Tamás <kjt@takarnet.hu>; +Cc: pgsql-sql

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




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: usernames of a group from SQL
@ 2006-05-21 08:04  kijato <kijato@gmail.com>
  parent: Achilleus Mantzios <achill@matrix.gatewaynet.com>
  0 siblings, 1 reply; 4+ messages in thread

From: kijato @ 2006-05-21 08:04 UTC (permalink / raw)
  To: pgsql-sql

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




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: usernames of a group from SQL
@ 2006-05-21 10:34  Markus Schaber <schabi@logix-tt.com>
  parent: kijato <kijato@gmail.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Markus Schaber @ 2006-05-21 10:34 UTC (permalink / raw)
  To: kijato <kijato@gmail.com>; +Cc: pgsql-sql

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




^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2006-05-21 10:34 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-05-19 08:40 usernames of a group from SQL Kis <kjt@takarnet.hu>
2006-05-19 10:04 ` Achilleus Mantzios <achill@matrix.gatewaynet.com>
2006-05-21 08:04   ` kijato <kijato@gmail.com>
2006-05-21 10:34     ` Markus Schaber <schabi@logix-tt.com>

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