Vérifier la validité d’une adresse email en PL-SQL

Usage des expressions régulières, quand tu nous tient 🙂

create or replace FUNCTION isEmail(Email IN VARCHAR2 )
RETURN boolean AS
email_dummy VARCHAR2(60);
BEGIN

SELECT
regexp_substr(Email,
‘[a-zA-Z0-9._%-]+@[a-zA-Z0-9._%-]+\.[a-zA-Z]{2,4}’)
INTO email_dummy
FROM dual;


IF (lv_email_dummy <> Email) OR( email_dummy is null) OR Length(TRIM(email_dummy))<3
THEN RETURN false;
END IF;

RETURN true;

exception
WHEN OTHERS THEN
RETURN false;
END isEmail;

Commentaires, conseils d’optimisations bienvenus !

This entry was posted in SQL and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *