using SQL function in FDM shows NULL results