Professional Documents
Culture Documents
-------------------------
1. It is a column data type
2. It is a pointer, it points to same address of the existing table.
3. It is a pointer, it inherits the specification of the one database table column
or entire database table or cursor specification.
4. It is based on the dynamic memory management concept.
5. The main concept of attribute data type is to reduce cost of maintenance.
6. It is classified into 2 types
a) %type
b) %rowtype
x.empno
x.ename
x.sal
x.deptno
--WAP accept a employee no and display his details with annual salary and
experience
declare
v_empno emp.empno%type:=&empno;
v_ename emp.ename%type;
v_job emp.job%type;
v_hdate emp.hiredate%type;
v_sal emp.sal%type;
v_deptno emp.deptno%type;
v_ann_sal number(10,2);
v_exp number(5,2);
begin
select ename,job,sal,hiredate,deptno
into v_ename,v_job,v_sal,v_hdate,v_deptno
from emp where empno=v_empno;
v_ann_sal:=v_sal*12;
v_exp:=trunc(months_between(sysdate,v_hdate)/12,2);
dopl('Empno : '||v_empno);
dopl('Ename : '||v_ename);
dopl('Job : '||v_job);
dopl('Salary : '||v_sal);
dopl('Deptno : '||v_deptno);
dopl('Annual sal : '||v_ann_sal);
dopl('Experience : '||v_exp);
end;
/
--WAP accept a employee no and display his details with annual salary and
experience
declare
e emp%rowtype;
v_ann_sal number(10,2);
v_exp number(5,2);
begin
e.empno:=&empno;
--WAP accept a employee number and calculate bonus based on the following
conditions and insert into bonus table.
Declare
v_empno emp.empno%type:=&empno;
v_sal emp.sal%type;
v_ann_sal number(8,2);
b bonus%rowtype;
begin
select sal into v_sal from emp where empno=v_empno;
v_ann_sal:=v_sal*12;
if v_sal>=5000 then
b.bonus_amt:=v_ann_sal*20/100;
b.add_amt:=2000;
elsif v_sal>=3000 then
b.bonus_amt:=v_ann_sal*15/100;
b.add_amt:=1500;
if v_sal>=1500 then
b.bonus_amt:=v_ann_sal*12/100;
b.add_amt:=1200;
else
b.bonus_amt:=v_ann_sal*10/100;
b.add_amt:=1000;
end if;
insert into
bonus(empno,bonus_amt,add_amt,iss_dt)values(v_empno,b.bonus_amt,b.add_amt,sysdate);
commit;
end;
/