1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| CREATE OR REPLACE FUNCTION "public"."majmeta" (text) RETURNS text AS
'
DECLARE
rec record;
curs refcursor;
metaid integer;
BEGIN
SELECT metanames.metaname_id INTO metaid
FROM section_metaname_roles, metanames
WHERE metanames.metaname_id=section_metaname_roles.metaname_id
AND section_metaname_roles.section_id IN
(SELECT section_id from sections WHERE code_role=\'issue\' and issue_id = $1) ;
OPEN curs FOR SELECT section_id from sections where sections.issue_id = $1 and code_role != \'issue\' ;
LOOP
FETCH curs into rec;
EXIT WHEN NOT FOUND;
INSERT INTO section_metaname_roles VALUES(rec.section_id, metaid, 70);
END LOOP;
CLOSE curs;
return;
END;
'
LANGUAGE 'plpgsql' ; |