Tuesday, June 19, 2018

Write pl/sql code for the followings: User enters emp_no,name and basic_salary for table STAFF, check basic_salary if it is less than 8000 then raise user define exception that salary is less than 8000 otherwise generate salary slip. Table: STAFF (Empno,Name,Basic_salary) Table:SALARYSLIP(EMPNO,BASIC_SALARY,HRA,DA,MA,ITCTAX,PT,PF, GROSSSALARY, NETSALARY) - DBMS (Exception)


 declare
 eno number(4);
 ename Staff.Name%type;
 sal Staff.Basic_Salary%type;
 lessthan exception;
 begin
 eno:=&eno;
 select Basic_Salary into sal from Staff where Empno=eno;
 if sal>58000 then
 raise lessthan;
 else
 sal:=sal+3000;
 select Name into ename from Staff where Empno=eno;
 insert into UpStaff values(eno, ename, sal);
 end if;
 exception when lessthan then
 dbms_output.put_line('Salary greater than 58000');
 when no_data_found then
 dbms_output.put_line('Empno not found');
 end;   

No comments:

Post a Comment