I want to create a function that checks whether a number entered is odd or even in PL/SQL.
I created this function but it is showing the compilation error.
code:
CREATE OR REPLACE FUNCTION YES_EVEN(p_val IN NUMBER) RETURN BOOLEAN AS
v_result BOOLEAN:= FALSE;
BEGIN
IF (p_val % 2) = 0 THEN
v_result := TRUE;
END IF;
RETURN v_result;
END;
/
Error:
I have tried to solve this but nothing happens.
CodePudding user response:
It isn't %
but MOD
, I presume.
if mod(p_val, 2) = 0 then ...