RDBMS SOLUTION


ASSIGNMENT 1 

SET A Q.3 SOLUTION

Write a PL/SQL block which will accept two numbers from user, check whether numbers are positive or negative. If positive number then display only the odd numbers between the entered numbers.




Source code:

    

    

    

/* set a Q.3 solution*/

 

 /*here will use 2 input and check if the numbers are positive or negative*/

/*declare variables*/

declare

a number:=:a;

b number:=:b;

i number; /*i will be used for getting value of a into i*/

begin

if(a>0 and b>0) then

    i:=a;

       loop

           if(mod(i,2)=0) then

             dbms_output.put_line(' ');

           else

              dbms_output.put_line(i||'is odd');

            end if;

              i:=i+1;

             exit when(i=b);

             end loop;

else

   dbms_output.put_line('entered an odd number');

end if;

end;

   

    
 Download code         next