Table1有6列代码,code1,%of code1,calc,code2,%of code2。
code code1 %ofcode1 calc code2 %ofcode2
1 a 20 + b 10
2 1 - c
3 2 10 * d 10
表2有两列字段,值。
field value
a 50
b 20
c 10
d 20
我需要使用函数
的最终计算值计算可能就像使用table1格式并从table2获取值。
50*20/100 + 20*10/100
12 - 10
2*10/100 * 20*10/100 = 0.4
我需要价值0.4
答案 0 :(得分:0)
您可以尝试沿着这些方向实施某些内容。
DECLARE
var_a VARCHAR2(50);
int_a NUMBER;
BEGIN
var_a := 'a'; -- SELECT code1 FROM Table1 WHERE code="input";
IF REGEXP_LIKE(var_a, '^\d+(\.\d+)?$')
THEN int_a := to_number(var_a, '9999.99');
ELSE int_a := (-16);-- SELECT value FROM Table2 WHERE field=var_a
END IF;
dbms_output.put_line('first int is: ' || int_a);
END;
/