Subject UDF Bug in Fb 1.0.3.972
Author Tomislav Avramovic
BUG IN FB 1.0.3.972
This Query
Q1:
select ff.id_artikal,
f_roundcurr(sum(ff.nab_cena)) vk_nab
from faktura ff
group by ff.id_artikal

Returns Error: Invalid Column Reference - 104

In IB56, FB1.0.794 and FB1.5RC6 works fine

Q2:
select f_roundcurr(sum(ff.nab_cena)) vk_nab
from faktura ff
Works fine

Q3:
select ff.id_artikal,
sum(f_roundcurr(ff.nab_cena)) vk_nab
from faktura ff
group by ff.id_artikal
Works fine

Interesting if I open another connection and open Q3 , but not unprepared
Q1 on first connection works fine. Something is cashed in server (UDF
declaration or something else).
If I close Q3 and unprepared on second connection, Q1 stop working.

If I open another connection and open Q2 (without group by)
Q1 on first connection return error.

Platform Win2000Pro
f_roundcurr is my UDF in FreeUDFLib.dll very similar to f_roundfloat
Same behaviour if I use f_roundfloat original function in FreeUDFLib

I can't use Q3 because My original Query is:

select f.id_fakt, f.broj, f.id_komintent, f.datum, k.naziv komintent,
k.karakter,
f_roundcurr(sum(ff.nab_cena*ff.kolicina)) vk_nab,
f_roundcurr(sum((ff.prod_cena*(1-ff.rabat/100))*ff.kolicina))
vk_prod,

f_roundcurr(sum(((ff.prod_cena*(1-ff.rabat/100))-ff.nab_cena)*ff.kolicina))
vk_marza,
f_roundcurr(sum(ff.danok*ff.kolicina)) vk_danok,

f_roundcurr(sum(((ff.prod_cena*(1-ff.rabat/100))+ff.danok)*ff.kolicina))
vk_proddan,
f_roundcurr(sum(ff.pldanok*ff.kolicina)) vk_pldanok,
f_roundcurr(sum((ff.danok-ff.pldanok)*ff.kolicina)) vk_razdan
from fak_hd f
left join komintent k on(k.id_korisnik=f.id_korisnik and
k.id_komintent=f.id_komintent)
left join faktura ff on(ff.id_korisnik=f.id_korisnik and ff.id_mag=f.id_mag
and ff.id_fakt=f.id_fakt)
where f.id_korisnik=:KOR_BR and
f.id_mag=:MAG_BR and
f.datum between :OD_DAT and :DO_DAT and
ff.kolicina>0
group by f.datum, f.broj, f.id_fakt, f.id_komintent, k.naziv, k.karakter

Regards,
Tomislav Avramovic
Halkyon Development Team