Step 1 - time how long this takes
for i in (select distinct * from table_A where class=in_class and grp_typ='N')
Loop
null;
end loop;
That tells you if you need to tune the outer query. Let's assume its quick
Step 2 - time these two
for i in (select distinct * from table_A where class=in_class and grp_typ='N')
Loop
if field_typ='2' then
proc_1(in_proc_id,in_proc_name,i.class,i.object_typ,in_year,in_period,i.t_id,i.groupend if;
end loop;
for i in (select distinct * from table_A where class=in_class and grp_typ='N')
Loop
if if field_typ='2' then
proc_2(in_proc_id,in_proc_name,i.class,i.object_typ,in_year,in_period,i.t_id,i.group_id,i.eff_dt,user_id);
end loop;
That tells you which of proc1 and proc2 to focus on first to get the biggest gains. I'll assume proc2 but since they are similar procs, the process is similar
Step 3 - Quick fixes
You're building a dynamic SQL every time (I assume because the table name is dynamic). You *might* get some benefits just by lowering the parse costs by sharing cursors. So put this at the start of proc_grp_ld
execute immediate 'alter session set cursor_sharing = force'
and reset at the end
execute immediate 'alter session set cursor_sharing = exact'
Step 4 - Refactoring code
In reality you only have 4 possible tables here (ABC, DEF, etc).
So you could write this as distinct inserts without all the dynamic stuff, ie the first insert would be:
insert into FINAL_GRP_TBL(T_ID,GROUP_ID,CLASS,A_VALUE,OBJECT_TYPE,YEAR,PERIOD)
SELECT DISTINCT A.T_ID,A.GROUP_ID,in_class,B.A_VALUE,in_object_typ,in_year,in_period
FROM table_A,
table_B,
ABC C,
( select distinct * from table_A where class=in_class and grp_typ='N'
and object_typ in('BU','BUL','AFF') <==== so just focussing on rows that yield ABC as the join table
) x
WHERE A.T_ID=x.in_t_id AND
A.GROUP_ID=x.in_group_id AND
A.GROUP_ID=B.GROUP_ID AND
C.EFFDT=(
SELECT MAX(C_EFF.EFFDT)
FROM s_tbl_nm C_EFF
WHERE C.s_fld_nm = C_EFF.v_fld_nm
AND C_EFF.EFFDT<= TO_DATE(in_period-in_year,MM-YYYY))
AND C.EFF_STATUS=A
AND B.A_VALUE= c.BUL
)
and then repeat for the other variations