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

แชร์
ฝัง
  • เผยแพร่เมื่อ 21 ก.ย. 2024

ความคิดเห็น • 34

  • @stephinstephen9598
    @stephinstephen9598 5 ปีที่แล้ว +5

    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;

  • @Simmlex
    @Simmlex 7 ปีที่แล้ว +9

    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.

    • @kashifihsan
      @kashifihsan 6 ปีที่แล้ว +1

      YOU ARE RIGHT . I DID IT.
      v_counter := v_counter + 1;
      v_test := (v_counter < 10);
      DBMS_OUTPUT.PUT_LINE(v_counter);

  • @helpingustayfit
    @helpingustayfit 2 ปีที่แล้ว

    With simple example you explain the concept very well. thank you Sir for awesome learning

  • @delvenacquire9005
    @delvenacquire9005 3 ปีที่แล้ว +2

    Instead of that if condition for terminate loop can we use exit when commend like
    EXIT WHEN v_counter >= 10; (Boolean program)

  • @shrav8426
    @shrav8426 8 ปีที่แล้ว +1

    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;

  • @nithyalakshmim8087
    @nithyalakshmim8087 4 ปีที่แล้ว +1

    set serveroutput on
    declare
    v_counter boolean:= true;
    v_num number:=0;
    v_res number;
    begin
    while v_counter loop
    v_num := v_num + 1;
    v_res := 19 * v_num;
    dbms_output.put_line(19||'X'||v_num||'='||v_res);
    if v_num>=10 then
    v_counter:=false;
    end if;
    end loop;
    end;
    /
    for multiplication table of 19 using a boolean expression

  • @vishalranjan2429
    @vishalranjan2429 3 ปีที่แล้ว

    dude you are saviour

  • @srajanjain2541
    @srajanjain2541 3 ปีที่แล้ว

    I appreciate your efforts ... but please don't put banner of LIKE THIS VIDEO or SUSCRIBE in middle of your teaching its disturbs a lot and distracts focus and attention as you having very good PL/SQL series. You put them in end only like you do. We always like,share & subscribe your video as its fruitful...thanks...Wishing you will try to improve this problem in your future videos.

  • @clearcoding3139
    @clearcoding3139 6 ปีที่แล้ว +1

    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;
    /

  • @manishshaw2393
    @manishshaw2393 4 ปีที่แล้ว +2

    Can anyone please tell me what is this IDE abd how to download it......nice explanation btw...thanks for making such videos✌️

    • @Rebellionrider
      @Rebellionrider  4 ปีที่แล้ว +6

      Thank you so much. I am really glad that you enjoyed my videos. Your appreciation means a lot to me. Regarding IDE, I am using a free tool offered by Oracle itself, it’s called SQL Developer. Check out this video here I have explained how to download and configure it.
      Step 1: Download and setup SQL Developer
      th-cam.com/video/zliF8kXVmeE/w-d-xo.html
      Step 2: How To Connect Your Database With SQL Developer
      Oracle 11g - www.rebellionrider.com/how-to-make-new-database-connection-in-sql-developer-rebellionrider/
      Oracle 12c - th-cam.com/video/tLFjwyHCEqk/w-d-xo.html
      Oracle 18c - th-cam.com/video/1gvN1A6xnxU/w-d-xo.html
      Thanks and have a great day!

  • @chanda_cartoon_handle
    @chanda_cartoon_handle ปีที่แล้ว

    Dear teacher,
    I have a problem with Boolean datatype v_test variable. I get message like this "v_test" must be declared. But I have declared it already. Could you help me?

  • @ubaidchougule
    @ubaidchougule 3 ปีที่แล้ว +1

    SET SERVEROUTPUT ON;
    DECLARE
    u_multiply BOOLEAN :=TRUE;
    u_counter NUMBER :=0;
    u_result NUMBER;
    BEGIN
    WHILE u_multiply LOOP
    u_counter:= u_counter +1;
    u_result :=16 * u_counter;
    DBMS_OUTPUT.PUT_LINE ('16'|| ' x '|| u_counter||' = '||u_result);
    IF u_counter >=10 THEN
    u_multiply :=FALSE;
    END IF;
    END LOOP;
    DBMS_OUTPUT.PUT_LINE ('LOOP ENDED.THANKS MANISH');
    END;
    /

  • @afiqrubiyan6954
    @afiqrubiyan6954 8 ปีที่แล้ว

    hi manish
    my question is what is the use of boolean expression as a test condition in while loop

  • @kumarkrori
    @kumarkrori 4 ปีที่แล้ว

    Hi Manish, I am executing a package.sp from shell script. How do I use SERVEROUTPUT ON for DBMS_OUTPUT.PUT_LINE?..please help

  • @maulikchaudhari9163
    @maulikchaudhari9163 3 ปีที่แล้ว +1

    SIR, I HAVE CONPLETED SQL. SIR IS IT COMPLETE SYLLEBUS FOR PLSQL FOR FRESHERS INTERVIEW ...?? PLZ SUGGEST ME SIR

    • @Rebellionrider
      @Rebellionrider  3 ปีที่แล้ว +1

      Yep this is the entire syllabus. Can't say anything about fresher interview but people from around the world messaged and commented that they got job after learning Oracle from this channel. Some even said that their interviewer asked the same question that I have listed down in my blogs. So, don't worry, learn from this channel and my blog (www.rebellionrider.com) and practice. All the best for your future 😊

  • @DamaraskaArya
    @DamaraskaArya 5 ปีที่แล้ว

    Is it can be debugged by without creating functions, proc or package?

  • @monkeyd.luffyd6775
    @monkeyd.luffyd6775 7 ปีที่แล้ว

    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;
    /

  • @sudhanshubaranwal6215
    @sudhanshubaranwal6215 5 ปีที่แล้ว

    Hi Manish,
    I tried 'dbms_output.put_line' just before starting of while loop but i am getting an error. Can you help me with that why i am getting an error

  • @nadunsamarasinghe5592
    @nadunsamarasinghe5592 ปีที่แล้ว

    set serveroutput on;
    declare
    vcounter number :=1;
    vresult number;
    vtest boolean :=TRUE;
    begin
    while vcounter

  • @SM-qd5vw
    @SM-qd5vw 7 ปีที่แล้ว

    sir please make video on static and dynamic sql

  • @Vykycy
    @Vykycy 7 ปีที่แล้ว

    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;

  • @vaibhavpatel1892
    @vaibhavpatel1892 7 ปีที่แล้ว

    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

  • @antonalmishev1784
    @antonalmishev1784 ปีที่แล้ว

    set SERVEROUTPUT ON;
    DECLARE
    v_counterA number :=1;
    v_counterB number :=1;
    v_result number ;
    v_stop boolean:=true;
    BEGIN
    while v_stop LOOP
    v_result := v_counterB*v_counterB;
    DBMS_OUTPUT.PUT_LINE(v_counterA || ' x ' || v_counterB || ' = ' || v_result);
    v_counterA := v_counterA +1;
    v_counterB:=v_counterB+1;
    IF v_counterA = 10 then v_stop := false;
    END IF;
    END LOOP;
    DBMS_OUTPUT.PUT_LINE('OUTSITE FROM THE LOOP');
    END;

  • @NormalIssues
    @NormalIssues 3 ปีที่แล้ว

    DECLARE
    v_counter NUMBER:=0;
    v_result NUMBER:=0;
    v_test BOOLEAN:= TRUE;
    BEGIN
    WHILE v_test LOOP
    v_counter := v_counter +1;
    v_result := 10*v_counter;
    DBMS_OUTPUT.PUT_LINE('10'||'x'||v_counter||'='||v_result);
    IF v_counter=10 THEN
    v_test:= FALSE;
    END IF;
    END LOOP;
    END;
    THANKS

  • @supriyosinha7800
    @supriyosinha7800 7 ปีที่แล้ว

    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;

  • @kapilchaudhary688
    @kapilchaudhary688 6 ปีที่แล้ว

    how to increse text size in sql developer ?

  • @Kapil1891
    @Kapil1891 6 ปีที่แล้ว

    How to come out from infinity loop?

    • @gummadinagalakshmi4083
      @gummadinagalakshmi4083 5 ปีที่แล้ว +1

      By using exit or exit when clause you can come out from infinity loop