0

有人可以帮助我使用以下代码:

  1. 我不确定为什么会引发错误
  2. RETURN (salary > min_sal) & (salary <=Max sal) - 这些有效吗?

当我运行代码时,我得到一个PLS 00049 BAD BIND error

Create or REPLACE FUNCTION sal_ok(SALARY number, jobgrade NUMBER)
RETURN BOOLEAN AS
BEGIN
SELECT losal, hisal INTO :min_sal, :max_sal FROM salgrade
WHERE grade = jobgrade;
RETURN (salary >=min_sal) AND  (salary <=Max sal);
END sal_ok;
/

感谢你的协助

4

1 回答 1

1

您遇到错误绑定错误的原因是您没有在函数中的任何地方声明min_salmax_sal变量。

照做

CREATE OR REPLACE FUNCTION sal_ok (salary NUMBER, jobgrade NUMBER)
    RETURN BOOLEAN
AS
min_sal number;
max_sal number;
BEGIN
    SELECT  losal, hisal
      INTO  min_sal, max_sal
      FROM  salgrade
     WHERE  grade = jobgrade;

    RETURN (salary >= min_sal) AND (salary <= max_sal); -- not sure about this line as   I am not sure what you would want to return
END sal_ok;
/

这将摆脱您的错误绑定错误。

关于您的退货声明,我不确定您想从您的函数中返回什么。

于 2013-06-16T12:45:12.220 回答