Link to home
Start Free TrialLog in
Avatar of Steve Berger
Steve BergerFlag for United States of America

asked on

How to do the calculation in the plsql loop?

Hi,

I have table like below

MODEL_NAME      ITEM_NUMBER      DA_VALUE
      A      A-1            2.1
      A      A-2            3.1
      A      A-3            1.1
      A      A-4            4.5
      B      B-1            3.2
      B      B-2            5.3
      B      B-3            7.2
      C      C-1            3.9
      C      C-2            4.0
      C      C-3            9.9
      
      
I need to write a stored procedure with 2 input values. One is design_code and another one is model_name. I will pass the model name as comma
separated values to the procedure. Model name is nothing but A,B,C in the above table. Procedure has to split those model names and display
all the item_numbers and da_numbers for the model names.

Here the logic is i have to take all the model's item da_value and multiply.

For example for the above table, I have to multiply all A-1 da_values and B-1 da_value and C-1 da_value then stored in to one array that result.
Again A-1 da_value and B-2 da_values and C-2 da_values then stored into the same array.
Again A-1 da_value and B-3 da_values and C-3 da_values then stored into the same array.

After that come to A-2 da_value and start B-1 da_value and C-1 da_value then store into the same array.
Again A-2 da_value and B-2 da_values and C-2 da_values then stored into the same array.
Again A-2 da_value and B-3 da_values and C-3 da_values then stored into the same array.

So like this only the flow should go for all the models. Below is the sample example.

v_variable := 2.1 * 3.2 * 3.9;
       A-1   B-1   C-1
            
v_variable := 2.1 * 5.3 * 4.0;
      A-1   B-2   C-2           
            
v_variable := 2.1 * 7.2 * 9.9;
       A-1   B-3   C-3
            
v_variable := 3.1 * 3.2 * 3.9;
       A-2   B-1   C-1           
            
v_variable := 3.1 * 5.3 * 4.0;
       A-2   B-2   C-2
            
The calculation should happen like above example. Can anyone share with your thoughts?

Thanks
ASKER CERTIFIED SOLUTION
Avatar of mrjoltcola
mrjoltcola
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial