         -- count references of referencing tables
         -- > 1 ref = extra delete function
         SELECT
-          parent_table,
-          owner,
-          count(parent_table) AS ref_count,
+          r.parent_table,
+          r.owner,
+          count(r.parent_table) AS ref_count,
           max(LEVEL) AS ref_depth
         FROM (
           SELECT

        ) mr
        OUTER APPLY (
          SELECT
            fk.table_name AS clean_parent
          FROM
            all_constraints fk
          JOIN

      -- if found = extra delete function to clean parent, except parent table = :1
      OUTER APPLY (
        SELECT
          fk2.table_name AS clean_parent
        FROM
          all_constraints fk
        JOIN
