view with a UDF calling an aggregate function adds quotes around the aggregate
I'm creating a view using the valid SQL:
SELECT dateAsString(MAX(a.dateStart)) AS LastDate ...
dateAsString is a UDF in my database that accepts a DATE parameter.
The query executes fine. When I save it in a view, though, dbForge changes the query text to:
dateAsString
(MAX(a.dateStart)
)
Which, obviously, won't work.
Any thoughts?
Could you please provide us the following information:
1. Version of the MySQL server.
2. CREATE definition of the UDF.
3. The assembly file containing the functions called by the UDF.
-
AdminDevart (_, Devart) commented
Hi,
Thanks for your post.
Please be informed that parentheses are automatically inserted after aggregate functions.
Best,
Devart Support Team -
Graham Charles commented
Yes, it seems to be a old version bug -- error present in 5.01, not in 5.5. So it'll be MySql's fault, not Devart's...
If you're still interested in seeing it happen, here's the function.
(Oh, and sorry, not a UDF, a stored function. Got my MSSQL/MySql terms mixed up.)
CREATE FUNCTION dateAsString(vDate datetime)
RETURNS char(10) CHARSET latin1
BEGINDECLARE ret char(10);
SET ret = CAST(
DATE_FORMAT(vDate, "%Y-%m-%d") AS char(10));RETURN ret;
END