Created
September 27, 2020 06:16
-
-
Save Amanullahgit/69194632996404ab41eaf5eee143b487 to your computer and use it in GitHub Desktop.
Write a PLSQL block using explicit cursor to calculate the gross salary for every employee from EMP table using following formula: Gross_salary=salary+(DA+HRA+TA) – TAX DA is 60% of salary HRA is 20% of salary TA is fix at 2000 TAX is 5% of salary
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*** | |
Write a PLSQL block using explicit cursor to calculate the gross salary for every employee from EMP table using following formula: | |
Gross_salary=salary+(DA+HRA+TA) – TAX | |
DA is 60% of salary | |
HRA is 20% of salary | |
TA is fix at 2000 | |
TAX is 5% of salary | |
***/ | |
SET SERVEROUTPUT ON | |
DECLARE | |
-- declaring variables | |
e_no emp.empno%type; | |
e_name emp.ename%type; | |
e_sal emp.sal%type; | |
da FLOAT; | |
hra FLOAT; | |
ta FLOAT; | |
tax FLOAT; | |
gross FLOAT; | |
-- end of declaration | |
-- declaring cursor | |
CURSOR c_gross is | |
SELECT empno, ename, sal, sal*0.60, sal*0.20, 2000, sal*0.05, sal+((sal*0.60)+(sal*0.20)+2000)-(sal*0.05) FROM emp; | |
--end of declaration | |
BEGIN | |
OPEN c_gross; | |
dbms_output.put_line('Emp_No Emp_Name Sal Da Hra Ta Tax Gross'); | |
dbms_output.put_line('----------------------------------------------------------------------------------------'); | |
LOOP | |
FETCH c_gross into e_no, e_name, e_sal, da, hra, ta, tax, gross; | |
EXIT WHEN c_gross%notfound; | |
dbms_output.put_line(e_no || ' ' || e_name || ' ' || e_sal || ' ' || da || ' ' || hra || ' ' || ta || ' ' || tax || ' ' || gross); | |
END LOOP; | |
CLOSE c_gross; | |
END; | |
/ |
please give a output...
Hey HETVI, you can download the file and run it using SQLPLUS, for output.
Thanks,
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
please give a output...