Subject Re: [firebird-support] no current record for fetch operation. (a little different)
Author Dmitry Yemanov
Mitch Peek wrote:
>
> However, I am getting this error without a procedure involved, and I
> have not seen that addressed.

This is also known and IIRC registered in the bug-tracker.

> 14 from transact t
> 15 join Transtype tt on tt.Id=t.Transtype_Id
> 16 left join transdetail td on t.store_id=td.store_id and
> t.id=td.transact_id
> 17 left join person p2 on p2.id=t.Assoc_Disc_Id
> 18 join till tl on tl.store_id=t.store_id and tl.id=t.till_id
> 19 left join pricing p on p.id=td.pricing_id
> 20 join payment pm on pm.store_id=t.store_id and pm.transact_id=t.Id
> 21 join pmtmethod pmd on pmd.id=pm.pmtmethod_id
> 22 left join distribution d on d.id=p.distribution_id
> 23 left join stock2cat sc on sc.id=d.stock2cat_id
> 24 left join stock s on s.id=sc.stock_id
> 25 join person2type pt on pt.id=tl.cashier_id
> 26 join person ps on ps.id=pt.person_id

Place all LEFT joins after INNER ones and it should solve your issue:

from transact t
-- inner joins
join Transtype tt on tt.Id=t.Transtype_Id
join till tl on tl.store_id=t.store_id and tl.id=t.till_id
join payment pm on pm.store_id=t.store_id and pm.transact_id=t.Id
join pmtmethod pmd on pmd.id=pm.pmtmethod_id
join person2type pt on pt.id=tl.cashier_id
join person ps on ps.id=pt.person_id
-- outer joins
left join transdetail td on t.store_id=td.store_id and t.id=td.transact_id
left join person p2 on p2.id=t.Assoc_Disc_Id
left join pricing p on p.id=td.pricing_id
left join distribution d on d.id=p.distribution_id
left join stock2cat sc on sc.id=d.stock2cat_id
left join stock s on s.id=sc.stock_id


Dmitry