I want to check if an email address given as an input is valid or not. I have created the following function. The function is created successfully but when I try running the function I am unable to get the desired output.
CREATE OR REPLACE FUNCTION email_validate(p_email IN varchar2)
return BOOLEAN
is
emailregexp constant varchar2(1000):= '^[a-z0-9._-]+@[a-z0-9.-]+\.[a-z]{1,10}$';
BEGIN
IF regexp_like(p_email,emailregexp ,'i') THEN
RETURN true;
ELSE
RETURN false;
END IF;
END;
The way I am trying to check the output is:
DECLARE
result BOOLEAN;
BEGIN
result:= email_validate('abcd@gmail.com');
dbms_output.put_line(result);
END;