Skip site navigation (1) Skip section navigation (2)

Re: [SQL] Question about PL/pgSQL

From: Kovacs Zoltan Sandor <tip(at)pc10(dot)radnoti-szeged(dot)sulinet(dot)hu>
To: Vladimir Terziev <vlady(at)school(dot)digsys(dot)bg>
Cc: pgsql-sql(at)postgreSQL(dot)org
Subject: Re: [SQL] Question about PL/pgSQL
Date: 2000-02-17 12:26:52
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
>       Can anybody help me how to declare and use an text array in PL/pgSQL
This plpgsql function answers the question whether a user (from
pg_shadow) is a member of the groups (pg_group), reading the array column
of pg_group. Unfortunately, I could not change any array item nor append
the array. I am afraid it is impossible, remembering Peter Eisentraut's

You might find something similar in contrib/array/.


CREATE FUNCTION is_a_group_member (int4,varchar) RETURNS bool AS'
    rename $1 to userno;
    rename $2 to group;
    groupno integer;
    listelement int4;
    i integer;
    b bool;
    yesno bool;
    select into groupno grosysid from pg_group where group = groname;
    if not found then
	raise exception ''Non-existing group'';
	end if;
    i = 0; b = ''t''; yesno = ''f'';
    while b loop
	i = i + 1;
	select into listelement pg_group.grolist[i]
	    from pg_group where groupno = grosysid;
	if listelement is null then
	    b = ''f'';
	    end if;
	if b and userno = listelement then
	    yesno = ''t'';
	    end if;
	end loop;
    return yesno;

In response to

pgsql-sql by date

Next:From: Mohit MarwahaDate: 2000-02-18 13:28:50
Subject: Kindly stop sending please !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1
Previous:From: Vladimir TerzievDate: 2000-02-17 09:52:48
Subject: Question about PL/pgSQL

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group