使用sql或plsql从兴趣配置中找到total_charge
START_FROM END_TO PER_UNIT CHAR_PU MIN_CHAR MAX_CHAR INSTRUCTION
---------- ---------- ---------- ---------- ---------- ---------- -------------
0 9999 1000 3 10 0 compare min
10000 29999 1000 2.5 3 0 add min
30000 99999 1000 2 0 0 compare
100000 999999 1000 1.5 0 300 compare max
步骤:
答案 0 :(得分:0)
CREATE OR REPLACE FUNCTION calcu(amount NUMBER) RETURN NUMBER is charge NUMBER;
BEGIN SELECT ((amount/per_unit)*char_pu) into charge from a where amount between start_from and end_to; if (charge<10) then charge:=10; elsif(amount between 10000 and 29999) then charge:=charge+3; elsif(charge>300) then charge:=300;
end if; RETURN charge; END calcu; select calcu(&amount) as charge from dual;