0

I have a query like this:

SELECT * 
FROM employees emp 
WHERE emp.loc = 'US' 
  AND usr.fnctn('emp_sal', :sal1, :sal2);

This query causes an error:

ORA-00920: invalid RELATIONAL OPERATOR

My function just returns the highest and the lowest sal in employees table

6
  • 3
    Where is your question, what do you want to achieve? Commented Sep 9, 2019 at 6:41
  • I'm very sorry sir. Just edited it. Commented Sep 9, 2019 at 6:46
  • You can not use boolean inside of sql, so fnctn must return something else and therefore you need some relation to compare the return value with. Commented Sep 9, 2019 at 7:14
  • 1
    Your function returns two values? Not possible except it returns collection. Commented Sep 9, 2019 at 7:18
  • 1
    "docs.oracle.com/cd/B28359_01/appdev.111/b28370/…" - "Avoid using OUT and IN OUT with functions. The purpose of a function is to take zero or more parameters and return a single value. Functions must be free from side effects, which change the values of variables not local to the subprogram." Commented Sep 9, 2019 at 8:19

1 Answer 1

3

A function returns a value.

In the where clause you need to compare that return value with something, e.g.

SELECT * 
FROM employees emp 
WHERE emp.loc = 'US' 
AND usr.fnctn('emp_sal', :sal1, :sal2) = 42;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.