16 lines
374 B
PL/PgSQL
16 lines
374 B
PL/PgSQL
set check_function_bodies = off;
|
|
|
|
CREATE OR REPLACE FUNCTION public.grp_add_members(to_grp integer, add_usrs integer[])
|
|
RETURNS void
|
|
LANGUAGE plpgsql
|
|
AS $function$
|
|
begin
|
|
insert into public.grp_usr (grp, usr)
|
|
select to_grp, usr_id
|
|
from unnest(add_usrs) usr_id
|
|
left join public.grp_usr gu on gu.usr = usr_id and gu.grp = to_grp
|
|
where gu is null;
|
|
end;
|
|
$function$
|
|
;
|