问题描述
在存储的函数中,我有:
formula := "(10+10 * 1000)/12";
(一个简单的数学公式,仅包含数字,动态创建为字符串)
(a simple math formula, with numbers only, dynamically created as a string)
我该如何评估并返回结果?
How do I eval this, and return the result ?
我不能使用EXECUTE(在存储的函数中是不可能的),如果我将其设为存储过程并从存储的函数中调用它,则会得到存储的函数或触发器中不允许使用动态SQL"-就像我将直接在函数内部进行评估.我需要一个存储的函数,而不是一个过程,因为我需要在SELECT语句中调用它.
I can't use EXECUTE (not possible inside a stored function) and if I make it a stored procedure and call it from a stored function, I get "Dynamic SQL is not allowed in stored function or trigger" -as if I would have the eval directly inside the function.I need a stored function, and not a procedure, because I need to call it inside a SELECT statement.
推荐答案
显然没有解决方案.我已经在PHP中应用了"paintfull"解决方法,因为它不是问题的主题,所以在此不再显示.
Apparently there is no solution to this.I have applied a "paintfull" workaround in PHP, which I will not display here as it is not the subject of the question.
这篇关于如何在MySQL存储的_function_中评估一个简单的数学公式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!