Я замутил пакет. Можете сказать, m и g у меня локальные переменные?
create or replace package BODY dolgi_pkgP is
procedure closemonth is
g number(4);
m number(2);
begin
select max(god)into g from potop;
select max(meseac) into m from potop a where a.god = g;
insert into potop(adres_id, lgoty_id, tarif, dolgi, potreblenie, meseac, god, itogo_meseac, total, fact_sum, potop_id)
select adres_id, lgoty_id, tarif+1, total-fact_sum, 0, meseacgod.fun_meseac(m), meseacgod.fun_god(m,g), null, null, null, potop_id.NEXTVAL
from potop
where meseac=m and god=g;
end closemonth;
end dolgi_pkgP;