tugas_DBMS3

by 08.05 0 komentar
Fitri Novita Sari
30109376
PIS 0904

simple LOOP







statemen for









statemen while










statemen exit dan exit when















contoh-contoh :

declare
x number(3);

begin
x:=&input_x;

for i in reverse 1..x LOOP
     dbms_output.put_line(x);

END LOOP;

end;
/












declare
x number(2);

begin
x:=&input_x;
for i in 1..x LOOP
   if mod(i,2)=1 then
   dbms_output.put_line(i||'ganjil');
   else 
   dbms_output.put_line(' genap');
   end if;
end loop;

end;
/













declare
x number(3);

begin
x:=&input_x;

for i in 1..x LOOP
     dbms_output.put_line(x);
     x:=x-1;
END LOOP;

end;
/














declare
x number(3);

begin
x:=&input_x;

for i in reverse 1..x LOOP
     dbms_output.put_line(x);

END LOOP;

end;
/














declare
x number(3);

begin
x:=&input_x;

for i in 1..x LOOP
     dbms_output.put_line(i);

END LOOP;

end;
/













declare
x number(3);

begin
x:=&input_x;

for i in 1..x LOOP
     if mod(i,2)=1 then
     dbms_output.put_line('tes'||i);
     end if;

END LOOP;

end;
/













declare
x number(3);
y number(3);
z number(3);

begin
x:=&input_x;
y:=&input_y;
z:=0;

for i in x..y LOOP
     if mod(i,3)=0 then
     z:=z+1;
     end if;
     end loop;

     dbms_output.put_line(' ada '||z||' buah angka yang habis di bagi 3 antara ' ||x|| ' dan '||y);
      
end;
/











declare
x number(3);
y number(3);
z number(3);
i number(3);

begin
x:=&input_x;
y:=&input_y;
i:=x;
z:=0;

While i <=y LOOP
     if mod(i,3)=0 then
     z:=z+1;
     end if;
     i:=i+1;
     end loop;
     dbms_output.put_line( ' ada ' ||z||' buah angka yang habis di bagi 3 antara ' ||x|| ' dan '||y);      
end;
/











DECLARE
total NUMBER(9); 
counter NUMBER(6); 
BEGIN
total := 0;
counter := 10;
LOOP
   total := total + counter; 
   EXIT WHEN total > 50; 
   DBMS_OUTPUT.PUT_LINE(' Total: ' || total);
END LOOP;
DBMS_OUTPUT.PUT_LINE('Counter: ' || counter);
END;
/













Unknown

Developer

Cras justo odio, dapibus ac facilisis in, egestas eget quam. Curabitur blandit tempus porttitor. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.

0 komentar:

Posting Komentar