12th Example - WHILE on PL/SQL



Other looping operator on the PL/SQL block is a WHILE. As with any other iteration operator,  WHILE operator able to process and display the value automatically at certain limits. WHILE has inverted logic if compared by LOOP, what does this mean? At initialization LOOP operator initial value of a variable is the smallest value (lower limit), while the operator WHILE loop variable initialization initial value is the largest value (upper limit). Here is an example of PL / SQL block that has the WHILE loop operator:

DECLARE
  jumlah NUMBER:=0;
BEGIN
  WHILE jumlah < 10 LOOP
    DBMS_OUTPUT.PUT_LINE(jumlah);
    jumlah := jumlah + 1;
  END LOOP;
END;
/

No comments

Powered by Blogger.