Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.3 kB
1
Indexable
Never
DECLARE
	-- v_employee_name Character(30);
	-- v_employee_salary OEHR_EMPLOYEES.SALARY%type;
	v_heading_employee Character(50) := 'Employee Name        Salary';
	v_heading_salary Character(50) := '---------------------------';
	-- You can declare a cursor over here or you can do it like you did in line 22 but for that you need the prompt variable declared first like below
	v_department_id OEHR_EMPLOYEES.DEPARTMENT_ID%type := :ENTERDEPARTMENT;
	-- CURSOR v_salaries_cursor IS
	-- 	SELECT FIRST_NAME || ' ' || LAST_NAME as employee_name,SALARY
	-- 	FROM
	-- 		OEHR_EMPLOYEES
	-- 	WHERE
	-- 		DEPARTMENT_ID = :EnterDepartmentID;
BEGIN
-- First approach
	-- OPEN v_salaries_cursor;
	-- 	FETCH v_salaries_cursor INTO v_employee_name,v_employee_salary;
	-- 	dbms_output.put_line(v_heading_employee);
	-- 			dbms_output.put_line(v_heading_salary);
	-- 	dbms_output.put_line(v_employee_name || ' ' || v_employee_salary);
	-- CLOSE v_salaries_cursor;
-- Using for loop everything above is done automatically (Second approach)
	FOR V_records IN (SELECT FIRST_NAME || ' ' || LAST_NAME as employee_name,SALARY	FROM OEHR_EMPLOYEES	WHERE	DEPARTMENT_ID = v_department_id)
		LOOP
			dbms_output.put_line(V_records.employee_name || '        ' || V_records.SALARY);
		END LOOP;
END;