Reputation: 1
Can someone help me with the code below:
RETURN (salary > min_sal) & (salary <=Max sal)
- are these valid? When I run the code I get a 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;
/
Thanks for your assistance
Upvotes: 0
Views: 142
Reputation: 14731
The reason why you are getting bad bind error is because you have not declared min_sal
and max_sal
variables anywhere in your function.
Do as
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;
/
This will get rid of your bad bind error.
Regarding your return statement, I am not sure what you would want to return from your function.
Upvotes: 1