ich hab eine mysql function, die mir immer den wert null liefert, aber ich verstehe nicht wieso, da sie eigentlich einen decimal wert liefern sollte. hier der code:
DELIMITER $$
CREATE DEFINER=dapro23
@localhost
FUNCTION foreignavg
() RETURNS decimal(10,3)
BEGIN
declare germancount decimal(1,0);
declare foreigncount decimal(1,0);
declare country Varchar(45);
declare avgc decimal(10,3);
declare nomorecountrys INT;
declare ga_cursor cursor for
select Country from Guestaddress Order by Country ASC;
declare exit handler for not found set nomorecountrys =1;
set nomorecountrys =0, germancount=0,foreigncount=0;
open ga_cursor;
while(nomorecountrys = 0) DO fetch ga_cursor into country;
if(country „Germany“) then set germancount=germancount+1;
else set foreigncount =foreigncount+1;
end if;
end while;
close ga_cursor;
set avgc=germancount/foreigncount;
return avgc;
END