Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
693 views
in Technique[技术] by (71.8m points)

stored procedures - How to use % in oracle for calculation

I have defined a logic where I want to use % percentage as a calculation but its giving me error while using.

Below is the logic.

ELSIF V_ANCHOR_NONANCHOR = 'Anchor'
THEN
v_STD_REVISED_AMT := (V_STANDRD_AMT  - v_OD_Discount) - ((V_STANDRD_AMT  - v_OD_Discount * 10%));

and the error is

Error(103,94): PLS-00103: Encountered the symbol "%" when expecting one of the following: ) , * & = - + < / > at in is mod remainder not rem => <an exponent (**)> <> or != or ~= >= <= <> and or like like2 like4 likec as between || member submultiset The symbol "%" was ignored.

Please suggest how to use it.

update

v_STD_REVISED_AMT := (V_STANDRD_AMT - v_OD_Discount) - ((V_STANDRD_AMT - v_OD_Discount * 0.1), (V_STANDRD_AMT - v_OD_Discount));

giving error as

Error(108,22): PLS-00412: list of values not allowed as argument to this function or procedure


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I think you just want the multiplication by 0.1 which is 10/100 means 10% as follows:

(V_STANDRD_AMT  - (v_OD_Discount * 0.1))

-- Update

The entire solution should be as follows:

v_STD_REVISED_AMT := (V_STANDRD_AMT  - v_OD_Discount) 
                     - CASE WHEN V_ANCHOR_NONANCHOR = 'Anchor' 
                              OR (M2_DATE_COL_VARIABLE < DATE '2019-03-31' 
                                  AND M2_DATE_COL_VARIABLE > DATE '2016-07-13') 
                            THEN (V_STANDRD_AMT  - v_OD_Discount * 10%)  
                            ELSE 0 
                       END;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...