the cursor does not print data

133 Views Asked by At

I have one task to solve.

Create a procedure that lists all employees who have a salary within ± 1000 of the entered value (any variable). The report will list: employee_id, first_name, last_name, hire_date, and salary.

Treat the case if there is no employee who has a salary in the range of the entered value.

Call a procedure for the value 10000.

I wrote this, Procedure is compiled and when I call it, it just prints PL/SQL procedure successfully completed.But no data from my database.

set serveroutput on;
create or replace procedure tisicka
  (p_salary in employees.salary%type)
is 
begin
  for cur_r in 
    (select employee_id, first_name, last_name, hire_date, salary 
     from employees where salary between p_salary+1000 and p_salary-1000
    )
  loop
    dbms_output.put_line(cur_r.employee_id ||', '|| cur_r.first_name ||', '|| cur_r.last_name ||', '||
      cur_r.hire_date ||', '|| cur_r.salary);
  end loop;
end tisicka;

exec tisicka(10000);

Can you please help me?

Thank you.

1

There are 1 best solutions below

0
On

You need to switch your BETWEEN clause from

between p_salary+1000 and p_salary-1000

to

between p_salary-1000 and p_salary+1000