-4
有一個過程查詢卡住了,heeeelp
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%」到最後,然後從程序中啓動這個報告(查詢) - 一切都會中斷請幫助 - 我該怎麼做?
什麼....... – yonan2236 2010-11-08 06:40:55
錯誤信息是什麼意思?...看起來像你想傳遞一個參數...但從哪裏? – 2010-11-08 06:52:31
參數?dog_no從程序FASTREPORT傳遞。 – Andrey 2010-11-08 06:54:53