有人可以帮我解决下面的代码:
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;
/
感谢您的协助
答案 0 :(得分:1)
您遇到错误绑定错误的原因是您未在函数中的任何位置声明min_sal
和max_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语句,我不确定你想从你的函数返回什么。