Sunday, February 22, 2009

(2) Write a pl - sql to find the greater no among three numbers.

SQL> edit
1 Declare
2 a number;
3 b number;
4 c number;
5 Begin
6 a:=&a;
7 b:=&b;
8 c:=&c;
9 if a>b and a>c then
10 dbms_output.put_line(a||'is greater');
11 elsif b>a and b>c then
12 dbms_output.put_line(b||'is greater');
13 elsif c>a and c>b then
14 dbms_output.put_line(c||'is greater');
15 end if;
16* end;
SQL> /


Output :

Enter value for a: 45
old 6: a:=&a;
new 6: a:=45;
Enter value for b: 40
old 7: b:=&b;
new 7: b:=40;
Enter value for c: 70
old 8: c:=&c;
new 8: c:=70;

PL/SQL procedure successfully completed.