1. Create a table using SQL*Plus

create table toc_multilevel (main_topic varchar2(100), sub_topic varchar2(100), page number);

2. Create an AFTER PARAMETER FORM trigger

function AfterPForm return boolean is
begin
  srw.set_format_order(srw.main_section, srw.header_section, srw.trailer_section);
  return (TRUE);
end;

3. Create a format trigger on F_PROD_SUBCATEGORY

function F_PROD_SUBCATEGORYFormatTrigge return boolean is
  PageNum number;
  myCount number;
begin
  -- get page number
  srw.get_page_num(pageNum);
  -- check table for duplicates
  select count(*)
  into myCount
  from toc_multilevel
  where main_topic = :PROD_CATEGORY and
  sub_topic = :PROD_SUBCATEGORY;
  -- if no duplicates, insert row
  	if myCount = 0 then
  		insert into toc_multilevel
  		values (:PROD_CATEGORY, :PROD_SUBCATEGORY, pageNum);
  	end if;
  return (TRUE);
end;

4. Create a SQL Query

SELECT * FROM TOC_MULTILEVEL
