查询卡住了 - heeeelp

时间:2010-11-08 06:38:30

标签: sql firebird

有一个程序

begin
if (exists(select * from dogovor where dog_main = :dog_no))
 then
 begin
  for select
       r.ref_str,
       ar.name,
       ar.inn,
       o.object_type_naz,
       cast((((cr1.CALC_total-cr1.calc_appear)*d.a_year)/m.a_year+0.00001)*100 as integer)/100,
       cast(((cr1.CALC_total*d.a_year)/m.a_year+0.00001)*100 as integer)/100,
       cast((((cr2.CALC_DEBIT_PENI-cr1.CALC_DEBIT_PENI)*d.a_year)/m.a_year+0.00001)*100 as integer)/100,
       cast((((cr2.CALC_DISC_PENI-cr1.CALC_DISC_PENI)*d.a_year)/m.a_year+0.00001)*100 as integer)/100,
       cast((cr1.CALC_DISC_PENI+0.00001)*100 as integer)/100,
       cast((cr2.CALC_DISC_PENI+0.00001)*100 as integer)/100,
       cast(((sr.debit*d.a_year)/m.a_year+0.00001)*100 as integer)/100,
       cast(((sr.credit_peni*d.a_year)/m.a_year+0.00001)*100 as integer)/100,
       cast(((sr.credit*d.a_year)/m.a_year+0.00001)*100 as integer)/100,
       cast(((cr1.CALC_appear*d.a_year)/m.a_year+0.00001)*100 as integer)/100,
       cast((((cr2.CALC_TOTAL-cr2.calc_appear)*d.a_year)/m.a_year+0.00001)*100 as integer)/100,
       cast(((cr2.CALC_total*d.a_year)/m.a_year+0.00001)*100 as integer)/100
  from dogovor m
       left join dogovor d on (m.dog_no = d.dog_main)
       left join recviz ar on (ar.inn=m.ar_inn)
       left join calc_raschet (m.dog_no,:b,0) cr1 on (1=1)
       left join calc_raschet (m.dog_no,:e,0) cr2 on (1=1)
       left join sum_raschet2(m.dog_no,:b,:e) sr on 1=1
       left join object o on (o.obj_no=d.obj_no)
       left join ras_refstr r on (r.rasrefstrid = o.object_type_naz)
   where m.dog_no=:dog_no
   and m.a_year<>0
   and o.obj_no is not null
 into :ref_str,
      :ar_name,
      :inn,
      :object_type_naz,
      :b_peni,
      :b_all,
      :d_peni,
      :disc_peni,
      :b_disc_peni,
      :e_disc_peni,
      :d_all,
      :c_peni,
      :c_all,
      :c1_all,
      :e_peni,
      :e_all
 do
 begin
  old_credit=0;
 if ((:b_all-:b_peni)>0) then
  begin
    if ((:b_all-:b_peni-:c_all)<=0) then
     old_credit=:b_all-:b_peni;
    else
     old_credit=:c_all;
  end
  suspend;
 end
end
else
begin
for select
       r.ref_str,
       ar.name,
       ar.inn,
       o.object_type_naz,
       (cr1.CALC_total-cr1.calc_appear),
       cr1.CALC_total,
       (cr2.CALC_DEBIT_PENI-cr1.CALC_DEBIT_PENI),
       (cr2.CALC_DISC_PENI-cr1.CALC_DISC_PENI),
       (cr1.CALC_DISC_PENI),
       (cr2.CALC_DISC_PENI),
       sr.debit,
       sr.credit_peni c_peni,
       sr.credit,
       cr1.CALC_appear,
       (cr2.CALC_TOTAL-cr2.calc_appear),
       cr2.CALC_total
from dogovor m
       left join recviz ar on (ar.inn=m.ar_inn)
       left join calc_raschet (m.dog_no,:b,0) cr1 on (1=1)
       left join calc_raschet (m.dog_no,:e,0) cr2 on (1=1)
       left join sum_raschet2(m.dog_no,:b,:e) sr on 1=1
       left join object o on (o.obj_no=m.obj_no)
       left join ras_refstr r on (r.rasrefstrid = o.object_type_naz)
 where  (m.dog_no=:dog_no)
    and o.obj_no is not null
 into :ref_str,
      :ar_name,
      :inn,
      :object_type_naz,
      :b_peni,
      :b_all,
      :d_peni,
      :disc_peni,
      :b_disc_peni,
      :e_disc_peni,
      :d_all,
      :c_peni,
      :c_all,
      :c1_all,
      :e_peni,
      :e_all
do
 begin
  old_credit=0;
 if ((:b_all-:b_peni)>0) then
  begin
    if ((:b_all-:b_peni-:c_all)<=0) then
     old_credit=:b_all-:b_peni;
    else
     old_credit=:c_all;
  end
  suspend;
 end
end
end

有一个查询

SELECT
    ar.name,
    (ro_1.e_all) / 1000 zadolzhenost_1,
    (ro_1.d_all + (ro_1.e_peni - ro_1.e_disc_peni) - (ro_1.b_peni - ro_1.b_disc_peni) - (ro_1.c_all - ro_1.old_credit)) / 1000 tek_zadolzhennost_1,
    (ro_1.b_all - ro_1.c_all) / 1000 pros_zadolzhennost_1,
    (ro_1.e_peni - ro_1.e_disc_peni) / 1000 peni_1,

    (ro_2.d_all + (ro_2.d_peni - ro_2.disc_peni)) / 1000 nap_2009,
    (ro_2.c_all) / 1000 pap_2009,

    (ro_2.e_all) / 1000 zadolzhenost_2,
    (ro_2.d_all + (ro_2.e_peni - ro_2.e_disc_peni) - (ro_2.b_peni - ro_2.b_disc_peni) - (ro_2.c_all - ro_2.old_credit)) / 1000 tek_zadolzhennost_2,
    (ro_2.b_all - ro_2.c_all) / 1000 pros_zadolzhennost_2,
    (ro_2.e_peni - ro_2.e_disc_peni) / 1000 peni_2,

    (ro_3.d_all + (ro_3.d_peni - ro_3.disc_peni)) / 1000 nap_2010,
    (ro_3.c_all) / 1000 pap_2010,

    (ro_3.e_all) / 1000 zadolzhenost_3,
    (ro_3.d_all + (ro_3.e_peni - ro_3.e_disc_peni) - (ro_3.b_peni - ro_3.b_disc_peni) - (ro_3.c_all - ro_3.old_credit)) / 1000 tek_zadolzhennost_3,
    (ro_3.b_all - ro_3.c_all) / 1000 pros_zadolzhennost_3,
    (ro_3.e_peni - ro_3.e_disc_peni) / 1000 peni_3
FROM
    dogovor d
LEFT JOIN recviz ar ON (ar.inn = d.ar_inn)
LEFT JOIN report_one (d.dog_no,'01.01.2008 00:00:00','01.01.2009 00:00:00') ro_1 on 1=1
LEFT JOIN report_one (d.dog_no,'01.01.2009 00:00:00','01.01.2010 00:00:00') ro_2 on 1=1
LEFT JOIN report_one (d.dog_no,'01.01.2010 00:00:00','01.10.2010 00:00:00') ro_3 on 1=1

WHERE d.dog_no = ?dog_no AND
(
    (ro_1.e_all >= '100000') OR
    (ro_2.e_all >= '100000') OR
    (ro_3.e_all >= '100000')
)

查询工作正常,但是如果我删除“d.dog_no =?dog_no”并将“@ filter%”放到最后,然后从程序中启动此报告(查询) - 一切都会崩溃请帮助 - 我该怎么办?

1 个答案:

答案 0 :(得分:2)

您需要查看快速报告中的传递参数。您是否阅读了手册?...检查this链接。看起来你必须用它的属性构建参数。尝试检查他们的论坛。文件似乎很简单。