album_and_subalbums
----- Recursive bulk updates! CREATE OR REPLACE FUNCTION album_and_subalbums(int) RETURNS SETOF int AS ' DECLARE ident record; ident2 record; BEGIN RETURN NEXT $1; FOR ident IN SELECT identifier FROM album f WHERE f.parent_album = $1 LOOP FOR ident2 IN SELECT * FROM album_and_subalbums(ident.identifier) LOOP RETURN NEXT ident2.album_and_subalbums; END LOOP; END LOOP; RETURN; END; ' LANGUAGE 'plpgsql';
Version 2.34
Still in use
= Version 2.34 =
----- Recursive bulk updates! CREATE OR REPLACE FUNCTION album_and_subalbums(int) RETURNS SETOF int AS ' DECLARE ident record; ident2 record; BEGIN RETURN NEXT $1; FOR ident IN SELECT identifier FROM album f WHERE f.parent_album = $1 LOOP FOR ident2 IN SELECT * FROM album_and_subalbums(ident.identifier) LOOP RETURN NEXT ident2.album_and_subalbums; END LOOP; END LOOP; RETURN; END; ' LANGUAGE 'plpgsql';