The following PLSQL code creates a database function that counts the number of sub-pages on a page (folder) in Oracle Portal. This function can then be called whenever a sub-page count is required.
create or replace
FUNCTION COUNT_PAGE_SUBPAGES(PPAGEID IN NUMBER) RETURN NUMBER AS
-- This function counts the number of subpages on a specified page.
-- It returns the count or zero.
intCount NUMBER;
BEGIN
SELECT COUNT(ID) INTO intCount FROM WWPOB_PAGE$ WHERE PARENTID=PPAGEID;
RETURN intCount;
EXCEPTION WHEN OTHERS THEN
RETURN 0;
END COUNT_PAGE_SUBPAGES;