Experiment-14
Object : Write a PL/SQL code to calculate total sal of emp having empno 100. Table emp1 having following columns: empno,ename,bp,da,hra,total.
Requirement: windows XP, Oracle 9i.
Program Code:
SQL>
create table emp1
2
(empno varchar(5),
3
empname char(20),
4 bp
number(5),
5 da
number(5),
6 hra
number(5),
7
total number(10));
Table
created.
SQL> insert into emp1
values('E0001','Abhishek',5000,6000,7000,NULL);
1
row created.
SQL>
select * from emp1;
EMPNO
EMPNAME BP DA
HRA TOTAL
-----
-------------------- --------- --------- --------- ---------
E0001
Abhishek 5000 6000
7000
SQL>
declare
2 d
number(5);
3 h
number(5);
4 b
number(5);
5 t
number(10);
6
begin
7
select bp, da, hra into b,d,h from emp1 where empno='E0001';
8
t:=b+d+h;
9
update emp1 set total=t where empno='E0001';
10 end;
11 .
Output: SQL> /
PL/SQL
procedure successfully completed.
SQL>
select * from emp1 ;
EMPNO
EMPNAME BP DA
HRA TOTAL
-----
-------------------- --------- --------- --------- ---------
E0001
Abhishek 5000 6000
7000 18000
Result:The above program was created executed successfully without any
error.
0 comments:
Post a Comment