PL/SQL (MOSC)

MOSC Banner

For loop in pl sql not working

edited Jan 16, 2015 4:23AM in PL/SQL (MOSC) 22 commentsAnswered ✓

I want to run the loop from i=1 to i=12 and insert each value of M_1,M_2 and so on till M_12 in M_Maintenance  table.I have tried but it is not working.Please help me out.

The code which I have tried is:-

BEGIN

   FOR i IN 1 .. 12

   LOOP

      DECLARE

         M_i               NUMBER;

         MONTH_i_COUNT     NUMBER;

         M_i_Maintenance   NUMBER;

         MONTH_i_SUM       NUMBER;

      BEGIN

         SELECT   ROUND (

                     ( ( (SELECT   SUM (MONTH_i_COUNT)

                            FROM   XXBAXY.XXBAXY_BREAKDOWN_TAB

                           WHERE   LOSS_CAT = 'Maintenance Related Losses')

                        + (SELECT   MONTH_i_COUNT

                             FROM   XXBAXY.XXBAXY_BREAKDOWN_TAB

                            WHERE   LOSS_CAT = 'Maintenance Related Losses'

Tagged:

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center