HomeОбразованиеRelated VideosMore From: Manish Sharma

PL/SQL tutorial 12: PL/SQL WHILE Loop in Oracle Database

551 ratings | 61619 views
Iterative statements/loop series learn the concepts of While Loop in PL/SQL or In Oracle Database with Examples. also learn how to handle boolean expression in while loop ------------------------------------------------------------------------ ►►►LINKS◄◄◄ Blog : http://bit.ly/while-loop-in-pl-sql Previous Tutorial ► Simple Loop: https://youtu.be/AFx6QYcY1CU ------------------------------------------------------------------------- ►►►Let's Get Free Uber Cab◄◄◄ Use Referral Code UberRebellionRider and get $20 free for your first ride. ------------------------------------------------------------------------- ►Make sure you SUBSCRIBE and be the 1st one to see my videos! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ►►►Find me on Social Media◄◄◄ Follow What I am up to as it happens on https://twitter.com/rebellionrider https://www.facebook.com/imthebhardwaj http://instagram.com/rebellionrider https://plus.google.com/+Rebellionrider http://in.linkedin.com/in/mannbhardwaj/ http://rebellionrider.tumblr.com/ http://www.pinterest.com/rebellionrider/ You can also Email me at for E-mail address please check About section Please please LIKE and SHARE my videos it makes me happy. Thanks for liking, commenting, sharing and watching more of our videos This is Manish from RebellionRider.com ♥ I LOVE ALL MY VIEWERS AND SUBSCRIBERS
Html code for embedding videos on your blog
Text Comments (16)
Stephin Stephen (21 days ago)
Here is what you asked for, SET SERVEROUTPUT ON; DECLARE v_test BOOLEAN :=TRUE; v_counter NUMBER :=0; v_result NUMBER; BEGIN WHILE v_test LOOP v_counter := v_counter +1; v_result := v_counter * 19; DBMS_OUTPUT.PUT_LINE(v_counter||' x '|| 19 ||' = '||v_result); IF v_counter =10 THEN v_test := FALSE; END IF; END LOOP; DBMS_OUTPUT.PUT_LINE('Outside the Loop'); END;
KAPIL KUMAR (7 months ago)
how to increse text size in sql developer ?
Eslam Osama (9 months ago)
DECLARE v_test BOOLEAN := true; v_counter number :=0; v_result number; BEGIN WHILE v_test LOOP v_counter := v_counter +1; v_result := 5 * v_counter; dbms_output.put_line ( '5 ' || ' x '|| v_counter || ' = ' || v_result ); --loop termination code IF v_counter = 13 then v_test :=false; end if; END LOOP; dbms_output.put_line('OUTSIDE THE LOOP'); END; /
Kapil Ahirwar (9 months ago)
How to come out from infinity loop?
gummadi nagalakshmi (1 month ago)
By using exit or exit when clause you can come out from infinity loop
Clear Coding (1 year ago)
Answer of the home work: SET SERVEROUTPUT ON; DECLARE V_NUMBER NUMBER := '&ENTER_NUMBER'; V_TEST BOOLEAN := TRUE; V_COUNTER NUMBER := 0; V_RESULT NUMBER; BEGIN WHILE V_TEST LOOP V_COUNTER := V_COUNTER + 1; V_RESULT := V_NUMBER * V_COUNTER; DBMS_OUTPUT.PUT_LINE(V_NUMBER||' X '||V_COUNTER||' = '||V_RESULT); IF V_COUNTER = 10 THEN V_TEST := FALSE; END IF; END LOOP; END; /
Simmlex (1 year ago)
You can save the IF part at the end if you switch it to V_test := (v_counter < 10); The part inside the () is a true or false statement which will be false only when v_counter reaches or exceeds 10.
Kashif Ihsan (1 year ago)
YOU ARE RIGHT . I DID IT. v_counter := v_counter + 1; v_test := (v_counter < 10); DBMS_OUTPUT.PUT_LINE(v_counter);
Supriyo Sinha (1 year ago)
set SERVEROUTPUT ON; cl scr; DECLARE a NUMBER:=&Enter_the_number; b NUMBER:=0; c NUMBER; d boolean:=True; BEGIN while d loop b:=b+1; c:=a*b; DBMS_OUTPUT.PUT_LINE(a||'X'||b||'='||c); if b=10 then d:=false; end if; end loop; end;
MONKEY D. LUFFY :D (1 year ago)
set serveroutput on declare a boolean:=true; b number:=0; c number :=0; begin while a loop b:=b+1; c:=19*b; dbms_output.put_line('19 '||' x '||b||' = if b =10 then a:=false; end if; end loop; dbms_output.put_line('outside loop'); end; /
viki (2 years ago)
set SERVEROUTPUT ON declare v_test boolean :=true; v_counter number :=0; v_result number; v_constant constant number := 19; begin while v_test loop v_result:= v_constant * v_counter; v_counter:= v_counter +1; dbms_output.put_line(v_constant || 'x' || v_counter || '='|| v_result); if v_counter =100 then v_test :=false; end if; end loop; dbms_output.put_line('Outside the loop'); end;
S M (2 years ago)
sir please make video on static and dynamic sql
Vaibhav Patel (2 years ago)
why r u initialize v_counter as a 1 insted of 0 becoj in simple loop u have used 0 insted of 1 totally confused
mikko martin (2 years ago)
--Multiplication with BOOLEAN; declare v_test boolean := true; v_counter number := 0; v_result number; begin while v_test loop v_counter := v_counter +1; v_result := 20 * v_counter; dbms_output.put_line ('20 x' || v_counter || '=' || v_result); if v_counter >=10 then v_test := false; end if; end loop; end; /
AFIQ RUBIYAN (2 years ago)
hi manish my question is what is the use of boolean expression as a test condition in while loop
shra v (3 years ago)
Hi Manish, Please find the program for multiplication table of 8 till 12. SET SERVEROUTPUT ON; DECLARE v_test BOOLEAN := TRUE; v_counter NUMBER :=0; v_result NUMBER; BEGIN WHILE v_test LOOP v_counter := v_counter + 1; v_result := 8 * v_counter; DBMS_OUTPUT.PUT_LINE('8' || '*' || v_counter || '=' || v_result ); IF v_counter = 12 THEN v_test := FALSE; END IF; END LOOP; DBMS_OUTPUT.PUT_LINE('DONE'); END;

Would you like to comment?

Join YouTube for a free account, or sign in if you are already a member.