Q:

Write a program in PL/SQL to show the uses of nested loop

0

Write a program in PL/SQL to show the uses of nested loop.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

PL/SQL Code:

DECLARE
  m  PLS_INTEGER := 0;
  n  PLS_INTEGER := 0;
  k  PLS_INTEGER;
BEGIN
  <>
  LOOP
    n := n + 1;
    k := 0;
DBMS_OUTPUT.PUT_LINE ('The values of inner loop are: ');	
    <>
    LOOP
      k := k + 1;
      m := m + n * k; -- Sum several products
  
      EXIT inner_loop WHEN (k > 3);
DBMS_OUTPUT.PUT_LINE ('n='||TO_CHAR(n)||'  k='||TO_CHAR(k)||'  m='||TO_CHAR(m));		  
      EXIT outer_loop WHEN ((n * k) > 6);
    END LOOP inner_loop;
  END LOOP outer_loop;
  DBMS_OUTPUT.PUT_LINE
    ('The total sum after completing the process is: ' || TO_CHAR(m));
END;
/

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now