Friday, September 18, 2020

RDBMS PLSQL Program 6 While loop (Increment operation)

 set serveroutput on

declare

i number(10,2);

begin

i := &i;

while i<11

loop 

dbms_output.put_line(i);

i := i+1;

end loop;

end;

/

RDBMS PLSQL Program 5 Simple loop (Decrement operation)

 set serveroutput on

declare

i number(10,2);

begin

for  i in reverse 1..10

loop 

dbms_output.put_line(i);

end loop;

end;

/

RDBMS PLSQL Program 4 Simple loop (Increment operation)

set serveroutput on

declare

i number(10,2);

begin

i := &i;

loop 

dbms_output.put_line(i);

i := i+1;

exit when i = 11;

end loop;

end;

/

RDBMS PLSQL Program 3 If statement

 set serveroutput on

declare

i number(10,2);

begin

i := &i;

if i=1 then

dbms_output.put_line('black tea');

elsif i=2 then

dbms_output.put_line('green tea');

else

dbms_output.put_line('pink tea');

end if;

end;

/

RDBMS PLSQL Program 1 Hello World

 SET serveroutput ON

BEGIN

     DBMS_OUTPUT.PUT_LINE('Hello World');

END;

/

RDBMS PLSQL Program 2 Basic Input Output

 SET SERVEROUTPUT ON 

DECLARE

    i number(10,2);

    str1 varchar(20);

BEGIN

i := &i;

if i = 2 then 

DBMS_OUTPUT.PUT_LINE('Input rejected');

else

str1 := '&str1'; 

DBMS_OUTPUT.PUT_LINE('Value of str =' || str1 );

end if;

END;

/