【问题标题】:the cursor does not print data光标不打印数据
【发布时间】:2021-08-19 22:11:50
【问题描述】:

我有一个任务要解决。

创建一个程序,列出工资在输入值± 1000 以内的所有员工(任何变量)。该报告将列出:employee_id、first_name、last_name、hire_date 和salary。

如果没有员工的薪水在输入值的范围内,则处理这种情况。

为值 10000 调用一个过程。

我写了这个,过程被编译,当我调用它时,它只是打印 PL/SQL 过程成功完成。但是我的数据库中没有数据。

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);

你能帮帮我吗?

谢谢。

【问题讨论】:

  • 你确定有工资在9000到11000之间的员工吗?
  • @Justin Cave 是的,我确定

标签: sql oracle plsql cursor no-data


【解决方案1】:

您需要将 BETWEEN 子句从

between p_salary+1000 and p_salary-1000

between p_salary-1000 and p_salary+1000

【讨论】:

    猜你喜欢
    • 2021-08-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-06
    • 2020-07-02
    • 1970-01-01
    • 2017-06-02
    • 2013-06-19
    相关资源
    最近更新 更多