DROP TABLE employees_temp CASCADE CONSTRAINTS PURGE;
CREATE TABLE employees_temp
AS
SELECT *
FROM employees;
DECLARE
CURSOR c1 IS
SELECT employee_id,
salary
FROM employees_temp
WHERE salary > 2000
AND ROWNUM <= 10; -- 10 arbitrary rows
CURSOR c2 IS
SELECT *
FROM (SELECT employee_id,
salary
FROM employees_temp
WHERE salary > 2000
ORDER BY salary DESC)
WHERE ROWNUM < 5; -- first 5 rows, in sorted order
BEGIN
-- Each row gets assigned a different number
UPDATE employees_temp
SET employee_id = ROWNUM;
END;
/
Using ROWNUM
0 comments:
Post a Comment