Oracle Apps Notes

A collection of my random notes, primarily on Oracle Apps

Logical operators in RETURN clause of a function

Here is what I learnt today.

You can use logical operators in the RETURN clause of a function whose return type is BOOLEAN. So for example, you can write a function with the following structure:

create or replace function test_fn(p_param varchar2)
return boolean
l_value varchar2(10):= 'TEST';
return false
or p_param = l_value
or length(p_param) = 5 ;
show errors;

The logical truth table is used to evaluate the expression in the RETURN clause and hence this function will return TRUE if the value passed to it is either TEST or any five-characters long string. For all other cases it will return FALSE.

Of course, the same logic could have been coded in lots of different ways but the example was just to show that this was one of the ways.

Comments are closed.

%d bloggers like this: