Search Postgresql Archives

Re: A function which returns all rolname from pg_roles.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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    === 


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux