比如这个字符串是'(2+3)*2+(3+2)%5',反正这个字符串中包括()+ - * / %数字都有!要把这个字符串转换为公式并且运算结果,求高手指点,最好写个函数!反正有办法点子都行!
比如to_number'(3+2)'是不行的
这样可以to_number('3'+'2'/2);
求知。。高手解决,谢谢!!!!!
比如to_number'(3+2)'是不行的
这样可以to_number('3'+'2'/2);
求知。。高手解决,谢谢!!!!!
scott@TBWORA> create or replace function f_cat(c_char varchar2)
2 return number
3 is
4 v_num number(18,4);
5 begin
6 execute immediate 'select '||c_char||' from dual' into v_num;
7 return v_num;
8 exception when others then
9 return null;
10 end;
11 /函数已创建。scott@TBWORA>
scott@TBWORA> select cat_str, f_cat(cat_str) as cat_result from tb;CAT_STR CAT_RESULT
---------------------------------------- ----------
(2+3)*2+(3+2)/5 11
-- 对头:注意:oracle 不认 % 运算符