select
EvalCalculate(
'case
when 1=1 then 1000*0.1-2+15/2
when 1=2 then 2000
when 1=3 then 3000
when 1=4 then 4000
else 4000-200*0.2
end '
)
from dual
--自定义函数
CREATE OR REPLACE FUNCTION EvalCalculate
(str in VARCHAR2) RETURN VARCHAR2
As
numval number;
begin
execute immediate 'select '||str||' from dual' into numval;
return numval;
end;
转载于:https://my.oschina.net/smartsmile/blog/814698