Tuesday, March 16, 2010

How to check valid email address

checking valid email address
=======================================

CREATE OR REPLACE PROCEDURE EMAIL_CHECK(EMAIL_ID VARCHAR2)
AS
VALID NUMBER;
BEGIN
SELECT 1
INTO VALID
FROM
(SELECT EMAIL_ID FROM DUAL)
WHERE REGEXP_LIKE(EMAIL_ID,'.*\@.*\..*');
IF VALID = 1 THEN
DBMS_OUTPUT.PUT_LINE('EMAIL ID ' || EMAIL_ID || ' IS NOT VALID');
ELSE
DBMS_OUTPUT.PUT_LINE('EMAIL ID ' || EMAIL_ID || ' IS VALID');
END IF;
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE('EMAIL ID ' || EMAIL_ID || ' IS NOT VALID');
END;



CREATE OR REPLACE PROCEDURE EMAIL_CHECK(EMAIL_ID VARCHAR2)
AS
BEGIN
IF OWA_PATTERN.MATCH(EMAIL_ID, '.*\@.*\..*')
THEN
DBMS_OUTPUT.PUT_LINE('Valid Email');
ELSE
DBMS_OUTPUT.PUT_LINE('InValid Email');
END IF;
END;

5 comments:

Anonymous said...

Excellent !!!! The better solution in web... Congratulation Friend !!

Unknown said...

very good solution thanks

Unknown said...

Very good solution. Thank you

Anonymous said...

Nice Solution Sir..... Thanx!!!!

Anonymous said...

... INTO VALID
FROM
(SELECT EMAIL_ID FROM DUAL
WHERE REGEXP_LIKE(EMAIL_ID,'.*\@.*\..*')
);
...
because a bracket is put in bad place !