Re: [SQL] Question about PL/pgSQL
От | Kovacs Zoltan Sandor |
---|---|
Тема | Re: [SQL] Question about PL/pgSQL |
Дата | |
Msg-id | Pine.LNX.4.05.10002171314540.22987-100000@pc10.radnoti-szeged.sulinet.hu обсуждение исходный текст |
Ответ на | Question about PL/pgSQL ("Vladimir Terziev" <vlady@school.digsys.bg>) |
Список | 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 advice. You might find something similar in contrib/array/. Regards, Zoltan CREATE FUNCTION is_a_group_member (int4,varchar) RETURNS bool AS' declare rename $1 to userno; rename $2 to group; groupno integer; listelement int4; i integer; b bool; yesnobool; begin select into groupno grosysid from pg_group where group = groname; if not found thenraise exception ''Non-existinggroup'';end if; i = 0; b = ''t''; yesno = ''f''; while b loopi = 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 anduserno = listelement then yesno = ''t''; end if;end loop; return yesno; end;
В списке pgsql-sql по дате отправления: