How to validate an Email in Sql

hello :),
i want to validate emails in my database .. it means that if a user enters a non valid email format ( not like : [email protected] ) an error has to be executed ( like in a trigger )
actually i am working on a jdbc project .. and i did an insert statement, there i have to check if the email format is right before inserting ..
thank you in advance :)..

You could try using the search
http://forums.oracle.com/forums/search.jspa?threadID=&q=%2Bvalidate+%2Bemail&objID=f75&dateRange=all
E.g.
validate email address pre-Oracle 10g
Function to verify email address' format?
Re: how to pass invalid characters as part of REGEX range?
Etc.

Similar Messages

  • How to Validate Multiple email address in spry?

    How to validate multiple email address in spry framework?
    Spry validate text field can validate one email address only,
    if I the text field is for multiple emails, how can I validate
    it?

    Hello Jackson,
    The Spry Textfield was designed to work with the normal work
    flows that people currently use in most of the forms on the web. We
    tried to prevent any email injection method in the forms therefore
    the validation was designed to stop any multiple email insertion.
    In case you want to insert multiple emails you'll have to
    disable the default email validation and create your own validation
    function, more flexible. You can see a
    sample
    we did for the custom validation trying to validate a password
    strength and confirm the password.
    Cristian

  • How to validate the Email in JSF 2.0

    Hi,
    I am developing web application using jsf2.0.
    In this case, I wish to validate the email field with the help of import org.hibernate.validator.Email;
    But it is not working, How to validate the email fileld...
    Thank.

    ManiForum wrote:
    ...I wish to validate the email field with the help of import org.hibernate.validator.Email;
    But it is not working, How to validate the email fileld...Are you asking on how to do it with the Email class from Hibernate? Or, are you open to other alternatives?

  • How to send automatic EMail from SQL or SAP B1

    hi experts as we are using SQL as DB i ned to send E-mails from sap system automatically but from SBO mailer  or Scheduler is not working from my side now i was planning to send emails from SQL can any one help me how to send emails automatically from SAP business one or from SQL

    Hi
    In SQL under Management\Database Mail
    You can configure account you use to send mails from SQL
    Then you can prepare procedure that will send mail
    for example
    EXEC msdb.dbo.sp_send_dbmail
    @profile_name = 'Hurtpol',
    @recipients = '[email protected]',
    @query = 'select isnull(syncherror,'''')  collate polish_ci_as
    from np.dbo.OITM
    where U_SynchStatus=''Failed''',
    --@body = @tresc,
    @subject = 'synch error'
    read about sp_send_dbmail

  • How to validate an email address against free domain users

    Hi all,
    I want to validate an email address so that only users of non free domains (let's say other than yahoo, hotmail, gmail, etc) can create an account in my apex application.
    I want to place a validation on the "Registration Page" but I am not sure how to proceed from then on :(
    Does anybody know how I can do this ?
    Kind Regards,
    Ana-Maria

    Hi Ana-Maria,
    You can do this on two places. You can do it on the client (using javascript) or you can do this on the database (using a trigger or a check constraint). The best way is to do both.
    Use something like this for the javascript bit:
    <script type="text/javascript">
    function checkemail(){
      var email = $v('P4_EMAIL');
      //get index of @
      var x = email.indexOf('@');
      //get the string behind @
      var behind_amp = email.substring(x+1, email.length);
      //get the index of the .
      var y = behind_amp.indexOf('.');
      //filter out the provider
      var provider = behind_amp.substring(0, y);
      var result;
      // set all wrong providers in this case
      switch(provider){
        case 'hotmail': result=false;break;
        case 'yahoo': result=false;break;
        case 'gmail': result=false;break;
      // Check the result
      if (!result){
        //The provider is bad
        alert(provider + ' is not allowed!');
        //Keep the focus on the email field
        setTimeout(function(){$x('P4_EMAIL').focus();}, 5);
    </script>Set the event to the onchange of the email field (in HTML Form Element Attributes):
    onchange="checkemail();"Hope this helps,
    Greetings Rutger

  • How to validate the Email string

    Hi all,
    How do you validate for a valid email string under regular expressions?
    Regards
    David

    Hi,
    Create an validation on EMAIL item and select Regular Expression as a validation method.
    Write the below coding in the regular expression validation method.
    ^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2}|(com|co.in|in|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$
    Regards,
    Sakthi.
    Edited by: Sakthi on Mar 18, 2011 2:22 AM
    Edited by: Sakthi on Mar 18, 2011 2:28 AM

  • How to validate an email in jsp

    Hi everyone, I am developing an web application in which i had to validate a user entered email address. Actually i developed some part of the code in jsp but its not so perfect because when a user enters more than one @ symbol,i am not able to detect it. Also there are some more bugs in it. So can anyone give me a sample code for this validation of an email-id. Also i heard that we have to use some regular expressions for this.Is it true? if so how? i need an idea.

    Create an InternetAddress using the email string:
    import javax.mail.InternetAddress;
    InternetAddress email = new InternetAddress(emailString);or
    InternetAddress email = new InternetAddress(emailString, true);If the address is not RFC822 valid, you should get an AddressException. If you set the address using the InternetAddress.setAddress(String s) method, then call validate(), which wil throw an AddressException on an invalid address.

  • How to validate a email address using Validation Pattern?

    Hi,
    is there any document for Validation Pattern? i m looking for a way to validate email addresses in my form.
    it's going to be something like * @ .
    i have no idea of how to do this, or maybe validation pattern is no good? use java script instead?
    any advice is appreciated!
    thanks.

    Hi erv2,
    You just need to place this script in the "exit" event of the field that u r using for email address.
    var r = new RegExp(); // Create a new Regular Expression Object.
        r.compile("^[a-z0-9_\\-\\.]+\\@[a-z0-9_\\-\\.]+\\.[a-z]{2,3}$","i");
    if( this.rawValue == null || this.rawValue == "")
    else
    var result = r.test(this.rawValue);                                              
    if (result == true) // If it fits the general form,
         true;               
    else
          xfa.host.messageBox("Please enter a valid email address ");
          this.rawValue = "";
          false;               // fail the validation.
    Thanks
    Amita
    Edited by: amita arora on Jan 20, 2009 10:44 AM

  • How to validate the email

    Hi all
    i have a text input contains email
    while save the record i need to check the filed that is valid email or not
    at least one @ and .(dot) symbol should check
    how its posible
    Regards
    Sree

    Hi,
    There are lot of regular expressions available on net. You can choose as per your requirement.
    Following is an example which checks most of the email types.
    public boolean validateEmail(String email) {       
    String regEx = "[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?";
    //Set the email pattern string
    Pattern p = Pattern.compile(regEx);
    //Match the given string with the pttern
    Matcher m = p.matcher(email);
    //check whether match is found
    boolean matchFound = m.matches();
    return matchFound;
    ~Mukesh U

  • How to validate the valid email

    Hi all
    i have a creation page in that page email field is ther .while saving the transaction i need to check that email is a valid email or not
    how can we achieve this functionality
    Regards
    Sreekanth

    Please see this link
    Re: how to validate the email
    Thanks
    --Anil                                                                                                                                                                                                                               

  • How to validate SQL scripts

    Hi,
    How to Validate SQL scripts?
    I am having set of sql files i wish to run one by one if there is any error at one file i need to notify to the user.I have created Bat file in-order to execute in a sequence.how to validate in bat file
    say
    01.sql ---Sucess
    02.sql --- Fail -- intimate and not to execute rest of sql files
    03.sql
    04.sql
    Thanks!

    933663 wrote:
    I am going to create the database
    cloneDBCreation.sql
    CloneRmanRestore.sql
    init.ora
    initEDIDBTemp.ora
    lockAccount.sql
    postDBCreation.sql
    postScripts.sql
    rmanRestoreDatafiles.sql
    dbname.bat
    dbname.sqlSo i need to validate each and every .sql whether it succeed or not. if there is failure then needs to notify the user. Use the SQL*Plus macro/command, WHENEVER SQLERROR EXIT <n>, to terminate a sql script when it hits an error - and have it return a specific exit code to the caller (o/s command line in this case). Note that exit codes are typically defined as a single byte in shells - which means it can only returns 0 to 255.
    In the command line shell, check the exit code of the previous command - which would be command than ran sqlplus and the sql script. If the exit code is for example 255, then you know the WHENEVER SQLERROR command was executed. And then you cease processing sql scripts.
    Simplistically (I do not do Windows), it will look as follows:
    --// sql script
    whenever sqlerror exit 255
    ... rest of the script
    @echo off
    rem command shell script
    prompt executing script 1
    sqlplus -s /nolog @sqlscript1.sql
    if ERRORLEVEL 255 goto :ScriptFailed
    prompt executing script 2
    sqlplus -s /nolog @sqlscript2.sql
    if ERRORLEVEL 255 goto :ScriptFailed
    goto :Success
    :ScriptFailed
    echo ...
    goto :End
    :Sucess
    echo ..
    goto :End
    :End

  • How to Validate the Domain for a given email id. Is a valid or invalid

    Hello Frndz,
    I am trying to validate the domain of a given email as a valid or invalid using the below SQL Block. But the values are hard coded into it.
    Please suggest me some way to validate the email id Domain dynamically, so that it can be identify that the domain exsists or not.
    Please help me. Thanks in advance.
    DECLARE
    l_domain_pos VARCHAR2(50);
    l_at_pos VARCHAR2(50);
    BEGIN
    FOR DOMAIN_CHCK IN (SELECT * FROM s_cnct_test WHERE PROCESSED ='N')
    LOOP
    BEGIN
    l_at_pos :=substr(DOMAIN_CHCK.email_addr,instr(DOMAIN_CHCK.email_addr,'@'));
    l_domain_pos := SUBSTR(l_at_pos,INSTR(substr(DOMAIN_CHCK.EMAIL_ADDR,instr(DOMAIN_CHCK.EMAIL_ADDR,'@')),'.'));
    IF ((l_domain_pos ='.com') OR(l_domain_pos ='.net')OR (l_domain_pos ='.nic.in') OR(l_domain_pos ='.co.in')) THEN
    UPDATE S_CNCT_TEST SET
    DOMAIN_STATUS ='Y',
    PROCESSED = 'Y',
    NEW_COMMENT = 'VALID DOMAIN'
    WHERE ROW_ID = DOMAIN_CHCK.ROW_ID;
    ELSE
    UPDATE S_CNCT_TEST SET
    DOMAIN_STATUS ='X',
    PROCESSED = 'N',
    NEW_COMMENT = 'NOT A VALID DOMAIN'
    WHERE ROW_ID = DOMAIN_CHCK.ROW_ID;
    END IF;
    COMMIT;
    END;
    END LOOP;
    END;

    Hi,
    Try something like this
    SQL> create table s_cnct_test(id not null primary key
                            ,email_addr, domain_status,processed, new_comment)
    as
        select 1, '[email protected]', 'Z1', 'N', 'D1**************************' from dual union all
        select 2, '[email protected]', 'Z2', 'N', 'D2***************************' from dual union all
        select 3, '[email protected]', 'Z3', 'N', 'D3*************************' from dual
    Table created.
    SQL> create table valid_domain(domain varchar2(64) not null
                             ,constraint valid_domain_pk primary key (domain))
    Table created.
    SQL> insert into valid_domain(domain)
        values ('.com')
    1 row created.
    SQL> insert into valid_domain(domain)
        values ('.net')
    1 row created.
    SQL> insert into valid_domain(domain)
        values ('.nic.in')
    1 row created.
    SQL> insert into valid_domain(domain)
        values ('.co.in')
    1 row created.
    SQL> commit
    Commit complete.
    SQL> create function domain(pi_email_addr in s_cnct_test.email_addr%type)
       return varchar2
       deterministic
    as
    begin
       return substr(substr(pi_email_addr, instr(pi_email_addr, '@'))
                    ,instr(substr(pi_email_addr, instr(pi_email_addr, '@')), '.'));
    end domain;
    Function created.
    SQL> update s_cnct_test s
       set domain_status =
              nvl((select 'Y'
                     from valid_domain
                    where domain = domain(s.email_addr)), 'X')
          , processed = nvl((select 'Y'
                     from valid_domain
                    where domain = domain(s.email_addr)), 'N')
          , new_comment =  nvl((select 'VALID DOMAIN'
                     from valid_domain
                    where domain = domain(s.email_addr)), 'NOT A VALID DOMAIN')
    where processed = 'N'
    3 rows updated.
    SQL> commit
    Commit complete.
    SQL> select *from s_cnct_test
            ID EMAIL_ADDR     DO P NEW_COMMENT                 
             1 [email protected]  X  N NOT A VALID DOMAIN          
             2 [email protected]   Y  Y VALID DOMAIN                
             3 [email protected] Y  Y VALID DOMAIN                
    3 rows selected.Regards
    Peter

  • How validate HTML using PL/SQL

    Hi,
    I try validate HTML using PL/SQL that user inputs.
    I did create below function for that purpose
    CREATE OR REPLACE
    FUNCTION validate_html(
      p_html IN VARCHAR2
    ) RETURN BOOLEAN
    AS
      l_comment  XMLTYPE;
      xml_parse_err EXCEPTION;
      PRAGMA EXCEPTION_INIT (xml_parse_err , -31011);
    BEGIN
      l_comment := xmlType.createXML('<root><row>' || p_html || '</row></root>');
      RETURN TRUE;
    EXCEPTION WHEN xml_parse_err THEN
      RETURN FALSE;
    END;
    Function works ok and return true if I run e.g.
    BEGIN
      IF validate_html('<p>Hello</p>') THEN
        dbms_output.put_line('OK');
      ELSE
        dbms_output.put_line('Not valid HTML');
      END IF;
    END;
    And return false if I enter not valid HTML like
    BEGIN
      IF validate_html('<p>Hello') THEN
        dbms_output.put_line('OK');
      ELSE
        dbms_output.put_line('Not valid HTML');
      END IF;
    END;
    But it return false also if I run below
    BEGIN
      IF validate_html('<p>Hello &nbsp</p>') THEN
        dbms_output.put_line('OK');
      ELSE
        dbms_output.put_line('Not valid HTML');
      END IF;
    END;
    Problem seems to be that &nbsp (there is ; in end but do not know how post it without forum convert that to space) witch is valid HTML for me.
    I know that HTML is not XML, but can I use Oracle database XML functions for validating HTML?
    How I should validate user inputted HTML?
    I'm currently developing this using Oracle XE 11G database.
    Regards,
    Jari

    Not an elegant way:
    But try this.........
    CREATE OR REPLACE FUNCTION validate_html (p_html IN VARCHAR2)
       RETURN BOOLEAN AS
       l_comment       XMLTYPE;
       xml_parse_err   EXCEPTION;
       PRAGMA EXCEPTION_INIT (xml_parse_err, -31011);
    BEGIN
       l_comment :=
          xmlType.createXML (
             '<root><row>'
             || CASE
                   WHEN INSTR (p_html, '&') > 0 THEN
                      UTL_I18N.escape_reference (p_html)
                   ELSE
                      p_html
                END
             || '</row></root>');
       RETURN TRUE;
    EXCEPTION
       WHEN xml_parse_err THEN
          RETURN FALSE;
    END;
    SET DEFINE OFF
    SET SERVEROUTPUT ON
    BEGIN
       IF validate_html ('<p>Hello') THEN
          DBMS_OUTPUT.put_line ('OK');
       ELSE
          DBMS_OUTPUT.put_line ('Not valid HTML');
       END IF;
    END;
    SET DEFINE OFF
    SET SERVEROUTPUT ON
    BEGIN
       IF validate_html ('<p>Hello &nbsp</p>') THEN
          DBMS_OUTPUT.put_line ('OK');
       ELSE
          DBMS_OUTPUT.put_line ('Not valid HTML');
       END IF;
    END;
    Cheers,
    Manik.

  • How to validate Email Address in HTML DB Application

    Hi,
    I have delevoped one Employee Login Details form in HTML DB. But i am unable to validate that email address as i find html db is not supporting String functions like indexOf(char c), substring(int) ect. So please can anybody help me to know how to validate email address that it has @ and . symbol or not.
    Thanks in advance.

    user529382,
    You may be able to use Regular Expressions instead, if you do a search in this forum for 'regex' you should find a few hits.
    While I agree that using a regular expression is a great way to verify that the user has entered an email address that conforms to the regular expression rules, it is still nothing more than that....conforming to the regular express rules.
    The only way to 100% confirm that an email address is 'valid', is to actually send an email to it, so what I tend to do is to get the user to enter their email twice (in a user registration screen for example), that way you can minimize the chance of 'typos', then send out a 'verification email' that the user has to click a link on to verify they have received it (I'm sure you've seen this type of system before), only when the confirmation is received would I then make the account 'active'.
    Hope this helps.

  • How can I validate a date using sql

    How can I validate a date using sql or pl/sql
    select to_date('01/01/2009','mm/dd/yyyy') from dual this is a good date
    but how can I check for a bad date
    select to_date('0a/01/2009','mm/dd/yyyy') from dual
    Howard

    William Robertson wrote:
    It'll be complicated in pure SQL, as you'll have to parse out day, month and year and then validate the day against the month and year bearing in mind the rules for leap years. It would be simpler to write a PL/SQL function and call that.Nah, not that complicated, you just need to generate a calender to validate against.
    SQL> ed
    Wrote file afiedt.buf
      1  with yrs as (select rownum-1 as yr from dual connect by rownum <= 100)
      2      ,mnth as (select rownum as mn, case when rownum in (4,6,9,11) then 30
      3                            when rownum = 2 then 28
      4                       else 31
      5                       end as dy
      6                from dual
      7                connect by rownum <= 12)
      8      ,cent as (select (rownum-1) as cen from dual connect by rownum <= 21)
      9      ,cal as (select cen, yr, mn,
    10                      case when ((yr = 0 and mod(cen,400) = 0)
    11                             or (mod(yr,4) = 0 and yr > 0))
    12                            and mn = 2 then dy+1
    13                      else dy
    14                      end as dy
    15               from cent, yrs, mnth)
    16  --
    17      ,dt as (select '&date_dd_mm_yyyy' as dt from dual)
    18  --
    19  select case when cal.cen is null then 'Invalid Date'
    20              when not regexp_like(dt,'^[0-9]{1,2}[\/.-_][0-9]{1,2}[\/.-_][0-9]{4}$') then 'Invalid Date'
    21         else dt
    22         end as dt
    23  from dt left outer join
    24               cal on (to_number(regexp_substr(dt,'[0-9]+')) between 1 and cal.dy
    25                   and to_number(regexp_substr(dt,'[0-9]+',1,2)) = cal.mn
    26                   and floor(to_number(regexp_substr(dt,'[0-9]+',1,3))/100) = cal.cen
    27*                  and to_number(substr(regexp_substr(dt,'[0-9]+',1,3),-2)) = cal.yr)
    SQL> /
    Enter value for date_dd_mm_yyyy: a1/02/2008
    old  17:     ,dt as (select '&date_dd_mm_yyyy' as dt from dual)
    new  17:     ,dt as (select 'a1/02/2008' as dt from dual)
    DT
    Invalid Date
    SQL> /
    Enter value for date_dd_mm_yyyy: 01/02/2008
    old  17:     ,dt as (select '&date_dd_mm_yyyy' as dt from dual)
    new  17:     ,dt as (select '01/02/2008' as dt from dual)
    DT
    01/02/2008
    SQL> /
    Enter value for date_dd_mm_yyyy: 29/02/2008
    old  17:     ,dt as (select '&date_dd_mm_yyyy' as dt from dual)
    new  17:     ,dt as (select '29/02/2008' as dt from dual)
    DT
    29/02/2008
    SQL> /
    Enter value for date_dd_mm_yyyy: 30/02/2008
    old  17:     ,dt as (select '&date_dd_mm_yyyy' as dt from dual)
    new  17:     ,dt as (select '30/02/2008' as dt from dual)
    DT
    Invalid Date
    SQL> /
    Enter value for date_dd_mm_yyyy: 29/02/2009
    old  17:     ,dt as (select '&date_dd_mm_yyyy' as dt from dual)
    new  17:     ,dt as (select '29/02/2009' as dt from dual)
    DT
    Invalid Date
    SQL> /
    Enter value for date_dd_mm_yyyy: 28/02/2009
    old  17:     ,dt as (select '&date_dd_mm_yyyy' as dt from dual)
    new  17:     ,dt as (select '28/02/2009' as dt from dual)
    DT
    28/02/2009
    SQL> /
    Enter value for date_dd_mm_yyyy: 0a/01/2009
    old  17:     ,dt as (select '&date_dd_mm_yyyy' as dt from dual)
    new  17:     ,dt as (select '0a/01/2009' as dt from dual)
    DT
    Invalid Date
    SQL> /
    Enter value for date_dd_mm_yyyy: 00/01/2009
    old  17:     ,dt as (select '&date_dd_mm_yyyy' as dt from dual)
    new  17:     ,dt as (select '00/01/2009' as dt from dual)
    DT
    Invalid Date
    SQL>

Maybe you are looking for