1 CREATE OR REPLACE FUNCTION DocmanTrashDir() RETURNS int4 AS '
5 FOR r IN select groups.group_id as gid from groups where groups.use_docman = 1 and groups.group_id not in(select doc_groups.group_id from doc_groups where doc_groups.groupname = ''.trash'' and doc_groups.stateid = 2) LOOP
6 INSERT into doc_groups (groupname, stateid, group_id) values (''.trash'',2,r.gid);
12 SELECT DocmanTrashDir() as output;