CREATE OR REPLACE PROCEDURE determineRaise(emp_name IN EMPLOYEES2.ename%type,
	total_raises OUT EMPLOYEES2.salary%type)
IS
	current_salary EMPLOYEES2.salary%type;
	current_raise EMPLOYEES2.salary%type;

	CURSOR curs_salary IS
		SELECT E.salary
		FROM EMPLOYEES2 E
		WHERE E.ename = emp_name;
BEGIN
	total_raises := 0;
	
	OPEN curs_salary;
	LOOP
		FETCH curs_salary INTO current_salary;
		EXIT WHEN curs_salary%notfound;
		IF current_salary < 50000 THEN
			current_raise := current_salary * 0.05;
		ELSIF current_salary < 100000 THEN
			current_raise := current_salary * 0.03;
		ELSE
			current_raise := current_salary * 0.01;
		END IF;
		total_raises := total_raises + current_raise;
		DBMS_OUTPUT.PUT_LINE('Raise for ' || current_salary || 
			' is ' || current_raise);
	END LOOP;
	CLOSE curs_salary;
END;
/
