Re: A function which returns all rolname from pg_roles.

From: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: A function which returns all rolname from pg_roles.
Date: 2006-07-11 05:09:45
Message-ID: 20060711050945.GA26967@webserv.wug-glas.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

am 10.07.2006, um 19:27:38 -0700 mailte Karen Hill folgendes:
> How do I make this function work? I am trying to get all the rolnames
> from pg_roles.
>
> CREATE OR REPLACE FUNCTION test() SETOF name AS $$
> DECLARE
> rrol name;
> BEGIN
> SELECT rolname INTO rrol FROM pg_roles;
> RETURN setof rrol;
> END;
> $$ LANGUAGE plpgsql;

CREATE OR REPLACE FUNCTION get_all_roles() returns setof text as $$
declare
rrol record;
begin
for rrol in select rolname from pg_roles loop
return next rrol.rolname;
end loop;
end;
$$ language plpgsql;

select * from get_all_roles();

HTH, Andreas
--
Andreas Kretschmer (Kontakt: siehe Header)
Heynitz: 035242/47215, D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net
=== Schollglas Unternehmensgruppe ===

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2006-07-11 05:27:49 Re: US Telephone Number Type
Previous Message Joe Conway 2006-07-11 04:57:02 Re: A function which returns all rolname from pg_roles.