Pl / sql错误绑定错误

时间:2013-06-16 12:29:11

标签: function plsql oracle11g

有人可以帮我解决下面的代码:

  1. 我不确定为什么会抛出错误
  2. RETURN (salary > min_sal) & (salary <=Max sal) - 这些有效吗?
  3. 当我运行代码时,我得到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;
    /
    

    感谢您的协助

1 个答案:

答案 0 :(得分: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;
/

这将消除您的错误绑定错误。

关于你的return语句,我不确定你想从你的函数返回什么。