Computer Science, asked by dmittal5221, 1 year ago

Write a pl/sql program to display the salary of a particular employee using functions

Answers

Answered by Cheemaking
1

Explanation:

Apparently there was some problem with the usage of the cursor.

The query can be simplified as :

SELECT * FROM ( SELECT EMPLOYEE, LAST_NAME, SALARY, RANK() OVER (ORDER BY SALARY DESC) emprank FROM emp ) WHERE emprank <= 3;

Answered by Anonymous
4

Explanation:

please ✪Hey There✪

Here is your program

SET VERIFY OFF;

DELETE FROM top_salaries;

DEFINE p_num = 5

DECLARE

num NUMBER(3) := &p_num;

sal employees.salary%TYPE;

CURSOR emp_cursor IS

SELECT distinct salary

FROM employees

ORDER BY salary DESC;

BEGIN

OPEN emp_cursor;

FETCH emp_cursor INTO sal;

WHILE emp_cursor%ROWCOUNT <= num AND emp_cursor%FOUND

LOOP

INSERT INTO top_salaries (salary)

VALUES (sal);

FETCH emp_cursor INTO sal;

END LOOP;

CLOSE emp_cursor;

END;/

SELECT * FROM top_salaries;

Hope It Helps.☺️

Similar questions