Reference no: EM132786026
Title - Income Tax Calculation using PL/SQL Function
Aim- To Calculate Income tax by accepting empno as a input. We assumed if Annual income is exceeded 500000 then employee incurred tax. Tax will be incurred on amount 10% of ( annual income-250000).
SQL*Plus: Release 10.2.0.1.0 - Production on Tue Feb 2 15:30:08 2021
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> connect
Enter user-name: system
Enter password:
Connected.
Employee Table
SQL> select * from emp;
EMPNO ENAME SAL DEPTNO JOB HIREDATE
---------- ------------ ---------- ---------- --------------- ---------
1000 Sachin 36250 10 Salesman 12-JAN-00
1001 Virat 76250 20 Forman 03-FEB-01
1003 Ajit 70000 20 Welder 09-AUG-98
1004 Rohit 73750 20 DBA 09-MAY-98
1005 Mahendra 67500 30 Manager 23-JUN-01
1006 Sai 68750 20 Manager 03-JUL-01
1007 kartik 70000 20 Manager 04-JUL-01
1008 Azhar 86250 20 Manager 04-JUL-01
1009 Mohhamad 123750 20 Manager 01-JUL-90
1010 Swati Patil 122500 10 Manager 01-JAN-88
1011 Azhar 150000 10 Salesman 01-JAN-99
EMPNO ENAME SAL DEPTNO JOB HIREDATE
---------- ------------ ---------- ---------- --------------- ---------
1012 Aniket 90000 90 Manager 09-APR-01
1002 Anita 78000 89 Teacher 01-JUN-00
2001 Sakshi 90000 90 Teacher 01-JAN-05
14 rows selected.
SQL> set serveroutput on;
SQL> create or replace function itCal(en number)
2 return number
3 is
4 annual_sal number;
5 it number;
6 begin
7 select sal*12 into annual_sal from emp
8 where empno=en;
9 if(annual_sal>500000)
10 then
11 it:=(annual_sal-250000)*0.10;
12 else
13 it:=0;
14 end if;
15 return it;
16 end;
17 /
Function created.
Testing Output Yield by Calling Function Itcal
SQL> selectitcal(1011) from dual;
ITCAL(1011)
-----------
155000
SQL> selectitcal(1003) from dual;
ITCAL(1003)
-----------
59000
SQL> selectitcal(1005) from dual;
ITCAL(1005)
-----------
56000
SQL> select itcal(1000) from dual;
ITCAL(1000)
-----------
0
SQL>
Attachment:- Income Tax Calculation using PL.rar