IF nested PL / SQL

1

Good Morning People; I ask for the collaboration of the community because I can not explain why the second if it is nested is not being evaluated, is not being evaluated and enters if the structure is true or false example (1 = 2) and enters? .. .

LOOP
FETCH c_cursor INTO ID_DOCUMENTO_DO, DIAS_VENCPRORRO, CON_PRORROGA, DIAS_VENCIMIENTO;
   EXIT WHEN c_cursor%NOTFOUND;
        IF (CON_PRORROGA > 0) then
            if(DIAS_VENCPRORRO >0)then
               INSERT INTO GEN_ALERTA
                           (DIAS_VENCIMIENTO)
                           VALUES (DIAS_VENCPRORRO);
             end if;
        ELSE
               INSERT INTO GEN_ALERTA
                           (DIAS_VENCIMIENTO)
                           VALUES (DIAS_VENCIMIENTO);
        END IF;
END LOOP;
    
asked by Gdaimon 23.03.2016 в 14:30
source

1 answer

1

I add the answer that I mentioned in a comment on the question. The Begin End block must be added in the if.

LOOP
FETCH c_cursor INTO ID_DOCUMENTO_DO, DIAS_VENCPRORRO, CON_PRORROGA, DIAS_VENCIMIENTO;
   EXIT WHEN c_cursor%NOTFOUND;
        IF (CON_PRORROGA > 0) then
            BEGIN
                  IF (DIAS_VENCPRORRO >0)then
                    BEGIN
                          INSERT INTO GEN_ALERTA
                           (DIAS_VENCIMIENTO)
                           VALUES (DIAS_VENCPRORRO);
                     END;
                  END IF;
            END;
        ELSE
            BEGIN
               INSERT INTO GEN_ALERTA
                           (DIAS_VENCIMIENTO)
                           VALUES (DIAS_VENCIMIENTO);
             END;
        END IF;
END LOOP;
    
answered by 23.03.2016 / 17:07
source