The following PLSQL code creates a database function that counts the number of items on a page in Oracle Portal. This function can then be called whenever an item count is required.
It creates the count by looking for items in the WWV_THINGS table where the parentid matches the id of the page you supply the function.
create or replace FUNCTION COUNT_PAGE_ITEMS(PPAGEID IN NUMBER) RETURN NUMBER AS
-- This function counts the number of items on a specified page.
-- It returns the count or zero.
intCount NUMBER;
BEGIN
SELECT COUNT(ID) INTO intCount FROM WWV_THINGS
WHERE CORNERID=PPAGEID;
RETURN intCount;
EXCEPTION WHEN OTHERS THEN
RETURN 0;
END COUNT_PAGE_ITEMS;