Here I am giving an example to validate email address using PL/SQL regular expressions (REGEXP) in Oracle.
Validate Email Using PL/SQL Program
In the following PL/SQL program, it will validate the email address using the REGEXP_LIKE function.
SET SERVEROUTPUT ON; DECLARE b_isvalid BOOLEAN; BEGIN b_isvalid := REGEXP_LIKE ('[email protected]', '^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$'); IF b_isvalid THEN DBMS_OUTPUT.put_line ('It is a valid email address.'); ELSE DBMS_OUTPUT.put_line ('It is Not a valid email address.'); END IF; END; /
Output
It is a valid email address. PL/SQL procedure successfully completed.
Get the List of Invalid Email Addresses from a Table Using SQL
The following SQL query will retrieve all the invalid email addresses stored in the EMAIL column of EMPLOYEES table in Oracle.
SELECT * FROM EMPLOYEES WHERE NOT REGEXP_LIKE (email, '^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$');
Similarly, to get the list of valid email addresses, delete NOT from the above query.
this does not pass some valid email addresses, example:
[email protected]
Hi Jonas,
I tested for the email id you mentioned and it is returning the correct result:
The above query returning a row, meaning it is the valid address.
can email id start with a dot (.) , this is passing it.
no ishould check only @ if it is not present in email it should show bounced in another column, and i want full code can you please do it in stored procedure
Hi I am Lokesh, I have one scenario can solve it and share that in plsql procedure and share to me pplease and expalin things how u solved
Can you post an example of using REGEXP_LIKE to validate a URL string?