Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2005.01.30;
Скачать: CL | DM;

Вниз

Где ошибка в триггере?   Найти похожие ветки 

 
}|{yk ©   (2004-12-23 14:35) [0]

---------------------------
Debugger Exception Notification
---------------------------
Project FinUchetMEM.exe raised exception class EFIBInterBaseError with message "DataModuleMain.Table_Plateg.InsertQuery:
Too many concurrent executions of the same request\n.
Too many concurrent executions of the same request.
". Process stopped. Use Step or Run to continue.
---------------------------
OK   Help  
---------------------------
AS
declare variable l_day integer;
declare variable l_month integer;
declare variable l_year integer;
declare variable l_rs varchar(14);
declare variable l_str varchar(82);
declare variable l_exist integer;
declare variable l_rule integer;
declare variable l_summa double precision;
declare variable l_kontragent integer;
declare variable l_rs_id_to integer;
declare variable l_set_to integer;
declare variable l_line_to integer;
declare variable l_cust1 integer;
declare variable l_cust2 integer;
declare variable l_cust3 integer;
declare variable l_unit integer;
begin
 l_kontragent = 483; /*ID контрагента*/
 l_cust1 = 0;                                      --iдентифiкатор CUST1
 l_cust2 = 80000096;                               --iдентифiкатор CUST2
 l_cust3 = 80000076;                               --iдентифiкатор CUST3

 select count(1) from app_pdv_move_rules a where a.reg_from = new.deb_kred
 and a.rs_id_from=new.rs_id into l_rule;
 if (l_rule=1) then
  begin
 /*вибираємо ID статті та ID рахунку, на який іде ПДВ*/
  select a.rs_id_to, a.set_to, a.line_to from app_pdv_move_rules a
  where a.reg_from = new.deb_kred and a.rs_id_from=new.rs_id into
  l_rs_id_to, l_set_to, l_line_to;
 /*-----------------------------------------------------------------*/
 select extract(DAY from new.plat_date) from rdb$database into l_day;
 select extract(MONTH from new.plat_date) from rdb$database into l_month;
 select extract(YEAR from new.plat_date) from rdb$database into l_year;
 select a.rs_name from app_rs a where a.rs_id=new.rs_id into l_rs;
 l_str = "Коригувальний платіж: ПДВ за "||l_day||"."||l_month||"."||l_year||" по рахунку "||l_rs;
 select count(1) from app_plateg a where a.koment = :l_str into l_exist;
    select sum(a.nds_sum) from app_plateg a
     where a.rs_id = new.rs_id and
           a.deb_kred = new.deb_kred and
           extract(day from a.plat_date) = extract(day from new.plat_date) and
           extract(month from a.plat_date) = extract(month from new.plat_date) and
           extract(year from a.plat_date) = extract(year from new.plat_date) into l_summa;
 if (l_exist>0) then
  begin
    update app_plateg a set a.plat_sum=coalesce(:l_summa,0) where koment = :l_str;
    update app_bank a set a.summa=coalesce(:l_summa,0) where a.plat_id = (select plat_id from app_plateg where koment = :l_str);
  end
   else
    begin
     /*дізнаємося ID підрозділу з таблиці рахунків*/
     select a.unit_id from app_rs a where a.rs_id = new.rs_id into l_unit;
     /*-------------------------------------------*/
     insert into app_plateg
       (plat_id,rs_id,kontr_id,plat_nom,plat_date,plat_sum,deb_kred,koment,read_only) values
       (gen_id(gen_app_plateg_id,1),:l_rs_id_to,:l_kontragent,"0000",new.plat_date, coalesce(:l_summa,0), new.deb_kred, :l_str,"Y");
       insert into app_bank (bank_id, plat_id, set_id, line_id, cust1_id,
                             cust2_id, cust3_id, unit_id, plat_date, rs_id,
                             avans_pogash, summa) values
                            (gen_id(gen_app_bank_id,1),gen_id(gen_app_plateg_id,0), :l_set_to, :l_line_to, :l_cust1,
                             :l_cust2, :l_cust3, :l_unit, new.plat_date, :l_rs_id_to,
                             "звичайний", coalesce(:l_summa,0));
    end
 end
end


 
}|{yk ©   (2004-12-23 14:54) [1]

Ошибка в
insert into app_plateg
(plat_id,rs_id,kontr_id,plat_nom,plat_date,plat_sum,deb_kred,koment,read_only) values
      (gen_id(gen_app_plateg_id,1),:l_rs_id_to,:l_kontragent,"0000",new.plat_date, coalesce(:l_summa,0), new.deb_kred, :l_str,"Y");

Но почему она возникает?


 
Sergey13 ©   (2004-12-23 15:20) [2]

Тригер на что и на когда?


 
Johnmen ©   (2004-12-23 15:27) [3]

Триггер на какую таблицу ?


 
}|{yk ©   (2004-12-23 15:45) [4]

Уже разобрался... Рекурсия может возникать...


 
Zacho ©   (2004-12-23 15:51) [5]

Я тебе уже как-то писал - скорее всего достигнута предельная глубина рекурсии. Точно рекурсии нигде нет ?

И ещё:
1. Вместо SELECT COUNT лучше использовать EXSIST - работает быстрее.
2. Вместо select extract(DAY from new.plat_date) from rdb$database into l_day; лучше l_day=extract(DAY from new.plat_date; и т.п.


 
}|{yk ©   (2004-12-24 12:05) [6]

Может кто подскажет?
Ошибка возникает из-за возникновения рекурсии.
То есть я заношу на 206 счет, и перенос тоже на 206 счет. И получаем бесконечный цикл.
Но.
Я добавил в начало такой код
 select count(1) from rdb$database where new.koment like "Коригувальний платіж:%" into l_recurse;
 
 if (:l_recurse=0) then

, который вроде как должен останавливать рекурсию, так как в автоматически формируемом платеже комментарий начинается из "Коригувальний платіж:%". Однако бесконечный цикл все равно есть :(


 
Johnmen ©   (2004-12-24 12:17) [7]

Остановить рекурсию можно единственным способом - не делать новых вставок из триггера...


 
}|{yk ©   (2004-12-24 12:23) [8]

То есть? Я же в начале триггера проверяю - автоматически ли это созданное поле, или нет. Если автоматически, то новая вставка должне происходить. А она происходит...


 
Zacho ©   (2004-12-25 11:05) [9]

2 }|{yk © :

А зачем тебе постоянно такие странные извращения с SELECT"ом из RDB$DATABASE ? Причём, нерабочие.

Проще надо быть..

if (new.koment like "Коригувальний платіж:%") then l_recurse=0;


 
Zacho ©   (2004-12-25 11:06) [10]

Zacho ©   (25.12.04 11:05) [9]

Ой, ошибочка :)

if (new.koment like "Коригувальний платіж:%") then l_recurse=1;



Страницы: 1 вся ветка

Текущий архив: 2005.01.30;
Скачать: CL | DM;

Наверх




Память: 0.49 MB
Время: 0.025 c
9-1098797748
А22
2004-10-26 17:35
2005.01.30
Voxel


3-1103908935
vixic
2004-12-24 20:22
2005.01.30
TDataSetProvider


14-1105613497
koshak
2005-01-13 13:51
2005.01.30
Delphi


1-1106137821
Jungle
2005-01-19 15:30
2005.01.30
Синхронизация БД и ActiveDirectory


3-1104065212
swinole
2004-12-26 15:46
2005.01.30
Инсталяция BDE