write program in pl/sql to print series 2 ,4, 6, 8, 10 using BASIC loop.
Share
write program in pl/sql to print series 2 ,4, 6, 8, 10 using BASIC loop.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Answer:
program in pl/sql to print series 2 ,4, 6, 8, 10 using BASIC loop
set serveroutput on;
DECLARE
i int;
BEGIN
i := 0;
LOOP
i := i+2
dbms_output.put_line(i);
exit WHEN x > 10
END LOOP;
END;
Output:
2
4
6
8
10
#SPJ3
Answer:
In PL/SQL, loops offer a mechanism to repeatedly run a certain section of a programme or a code statement whatever often is necessary. When it is unclear how often a piece of code will be repeated, a basic loop or simple loop is recommended in PL/SQL code. The code block will run at least once when we utilize the basic loop.
Explanation:
Two things should be kept in mind when utilizing it:
syntax:
LOOP
sequence of statements
END LOOP;
The loop in the program below is used to output numbers from 2 to 8 on the terminal, and the exit command is used to end the loop. Let's look at one more instance where the exit when statement will be used to end the loop.
Program:
set serveroutput on;
DECLARE
i int;
BEGIN
i := 0;
LOOP
i := i+2
dbms_output.put_line(i);
exit WHEN x > 10
END LOOP;
END;
Output:
2
4
6
8
10
#SPJ3