• Maybe add

    order by cat_name,sch_name,tab_name

    for the select statement from the temp table.