Monday, November 5, 2007

UPDATED AND EXECUTED

Hi, the programs here are executed perfectly under pl/sql standards... I remember you once again that you should set the server output to ON from the options to view the output.....Happy programming

code 3

3.Write a code to demonstrate plsql implicit cursors?
sol:
Declare
e tab2.eno%type;
n tab2.ename%type;
d tab2.deptno%type;
Begin
d:=&d;
update tab2 set sal=7000 where deptno=d;
if sql%found then
dbms_output.put_line('records updated');
else
dbms_output.put_line('no records updated');
end if;
end;
/


Bollywood, fun, friendship, sports and more. You name it, we have it.

code no 4 & 5

4.Write a plsql code to display the name of all employes working in a particular dept?
sol:
Declare
cursor c1 is select ename from tab2 where deptno=&d;
n tab2.ename%type;
Begin
open c1;
loop
fetch c1 into n;
exit
when c1%notfound;
dbms_output.put_line(n);
end loop;
close c1;
end;
/
5.Write a plsql code to disp names using explicit cursor?
sol:
Declare
cursor c1 is select ename from tab2;
n tab2.ename%type;
Begin
open c1;
loop
fetch c1 into n;
exit
when c1%notfound;
dbms_output.put_line(n);
end loop;
close c1;
end;
/


Find a mall, hotel or ATM in any part of India. Click here.

code no. 6&7

6.Write a plsql codeto display the first two maximum salaries on screen?
sol:
Declare
cursor c3 is select sal from tab2 order by sal desc;
s tab2.sal% type;
Begin
open c3;
loop
fetch c3 into s;
dbms_output.put_line(s);
exit when c3%rowcount>2;
end loop;
close c3;
end;
/

7.Write a pl/sql code to display first three salaries on the screen?
sol:
Declare
cursor c5 is select sal from tab2;
n tab2.sal%type;
Begin
open c5;
loop
fetch c5 into n;
dbms_output.put_line(n);
exit
when c5%rowcount>2;
end loop;
close c5;
end;
/


Get the freedom to save as many mails as you wish. Click here to know how.

2.display the name, city , eno, salary and bonus take eno as input from user on the screen in different rows

declare
n tab2.ename%type;
s tab2.sal%type;
c tab1.city%type;
b number;
e tab2.eno%type;
begin
select ename,sal, city into n, s, c from tab1,tab2 where tab1.deptno=tab2.deptno and eno= &e;
b:=&b;
b:=b+s;
dbms_output.put_line('name is '||n|| ' salary is ' ||s|| 'city is '||c||'bonus is ' ||b);
end;
/

1.DISPLAY THE NAME AND SALARY FROM EMPLOYEE TABLE

declare
n vachar(10);
s number(10);
begin
select ename, sal into n,s from emp where eno=&eno;
dbms_output.put_line('name is ' ||n|| 'and salary is' ||s );
end;

WAIT GUYS we are working

SITE UNDER CONSTRUCTION...........