December 23, 2015
Posted by on
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)
l_value varchar2(10):= 'TEST';
or p_param = l_value
or length(p_param) = 5 ;
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.