10 January 2015

5 basic Plsql programs till operators

Hi friends today i will show before you some plsql programs.After two post about plsql it is neccessary to see some programs example. I hope you will like it.

5 basic plsql programs:-

Q1.Write a PL/SQL code that display "Hello World" on the Screen.

1) begin
    dbms_output.put_line('Hello world');
 end;
 /




Q2.Write a PL/SQL code that accepts 2 numbers and display their sum,product,difference and quotient of two numbers.

2)declare
   num1 number(10) :=&number1;   --for taking user input and store it in num1 veriable
   num2 number(10) :=&number2;
   num3 number(10) ;

begin

    dbms_output.put_line('enter the first number: '||num1);
dbms_output.put_line('enter the first number: '||num1);
dbms_output.put_line('sumation of two number: '||(num1+num2));
dbms_output.put_line('substraction of two number: '||(num1-num2));
dbms_output.put_line('product of two number: '||(num1*num2));

dbms_output.put_line('quotient of two number: '||(num1/num2));
end;
/

Q3.Write a PL/SQL code that accept a float variable by radius and display the area and circumference.

3)declare
   radius number(05,2) :=&number1;
   cumc number(10,5);
  begin
    cumc:=(2*3.14*radius);
    dbms_output.put_line('circumference of circle: '||cumc);
     dbms_output.put_line('area of circle: '||(3.14*radius*radius));
  end;
/

Q4.Write a PL/SQL code that accepts width and height of a rectangle and display its area and perimeter.

4)declare
     width number(10,2) :=&number1;
     height number(10,2) :=&number2;
     begin
       dbms_output.put_line('area of rectangle is: '||(width*height));
       dbms_output.put_line('perimeter  of rectangle is: '||(2*(width+height)));
    end;
/

Q5.Write a PL/SQL code that accept principle,rate and time and display simple and compound interest.

5)declare
     p number(10) :=&number1;
      r number(10) :=&number2;
      t number(10) :=&number3;
     n number(10):=1;
      nt number(12,2):=(1*t);
     temp2 number;
     temp number(10);
      si number(10,3);
     ci number(10,3);
  begin
     temp2:=(r/n);
    si:=((p*r*t)/100);
     temp:=power((1+temp2),nt);
   ci:=(temp*p);
    dbms_output.put_line('simple interest is :'||si);
dbms_output.put_line('compound interest is :'||ci);
  end;
/

If you have some question then must ask.I will try to solve it.

you will also like:
Operators in pl sql

Introduction of pl sql

No comments:

Post a Comment

Ads Inside Post

Contributors