I suspect the answer to this is "No", based purely on the concept of type safety in general, but I shall ask anyway.
If I define a stored function in MySQL, normally part of the CREATE
syntax defines the return type of function.
Is it possible to define one where the return type is one of two possible types, depending on the result, but which is unknown to the caller? Specifically, I'm interested in specifying DECIMAL
types with two different precisions based on the value returned, so that I don't have to CAST
these values explicitly everywhere they are used.
I know that I can explicitly use, for example, CASE
and CAST
to change the precision in a stored procedure or regular statement, but I'd like to abstract that code away into a stored function.