Find none numeric in varchar field

We have a field that is supposed to store phone numbers, but it is VARCHAR2, don't ask me why it is, but it is and it's not going to be changed or fixed, I am just an end user.
Anyways, I would like to scan that entire column and find anything that is not a number, how would I do that ? when searching for non-number in a character field ?
REGEX ?

This
SQL> with t as ( select '1234568' col1 from dual union all
  2   select 'adff1354' from dual union all
  3    select '1235jhgjhgrfg' from dual union all
  4    select '8975444' from dual )
  5   select col1
  6   from t
  7   where regexp_replace(col1,'[0-9]') is null;
COL1
1234568
8975444
SQL> or
SQL> with t as ( select '1234568' col1 from dual union all
  2    select 'adff1354' from dual union all
  3     select '1235jhgjhgrfg' from dual union all
  4     select '8975444' from dual )
  5    select col1
  6    from t
  7    where regexp_replace(col1,'\d') is null;
COL1
1234568
8975444
SQL> Edited by: Salim Chelabi on Aug 13, 2009 4:22 PM

Similar Messages

  • How to check non-numeric value in a field

    Hi all,
    I have a field 'MVALUE'. HOw can I check if I have a non-numeric value in my field. Let us say if I have a value '<25' in this field. How can I check if the value in this field is non-numeric. The field MVALUE is of CHAR datatype.
    Please help. Waiting.........

    Might have to add a space in the string...
    if not mvalue co ' 0123456789'.
    * error
    endif.
    if you allow decimals and commas...
    if not mvalue co ' .,0123456789'.
    * error
    endif.

  • Sort a varchar field numerically

    select streetnum from address_points_sp where streetname='THORNWAY' and suffix='AVE' order by streetnum asc
    is the sql I'm trying to run. But StreetNum is defined as a varchar... unfortunately. I cannot change the DB schema. Is there a way to do this via sql?
    Also, I need to find out the lowest number and the highest....
    Thank you

    If you are quite sure that you'll only have Numeric data in streetnum field, try TO_NUMBER function.
    SQL> desc temp_1
    Name                                      Null?    Type
    COL_1                                              VARCHAR2(3)
    SQL>
    SQL> insert into temp_1 values ('3')
      2  /
    1 row created.
    SQL> commit
      2  /
    Commit complete.
    SQL> ed
    Wrote file afiedt.buf
      1  select to_number(col_1)+1 from temp_1
      2* where col_1 = '3'
    SQL> /
    TO_NUMBER(COL_1)+1
                     4But there is also a potential problem if you have non-numeric data in the field. Like below:
    SQL> select to_number(col_1) from temp_1
      2  /
    select to_number(col_1) from temp_1
    ERROR at line 1:
    ORA-01722: invalid numberCheers
    Sarma.

  • How to check a field in Message mapping wether it is Non Numeric?

    Hi XI Guru's
    I am totally new to XI world, Kindly help hopw can I chexk a field while doing message mapping whether the field is non numeric or not.
    I dont find any built in function for the same.
    If it is using UDF can some body help me in providoing a UDF for this.
    Many Thanks
    Arun

    Hi Arun,
    In SAP PI, all the XML contents by default treated as STRINGS.
    So if u want to check whether the incoming field is numeric or not... the only way is to write a UDF code for the same.
    the UDF will be,
    1. At first
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;
    in functions.
    2.UDF content:
    input: field,container
    output:boolean
    Code
    boolean return_Value;
    Pattern p = Pattern.compile("[0-9]*");          // If u are using the decimals please change the regular expression accordingly.
    Matcher m = p.matcher(field);
    if(m.matches())
    retuen_Value = true;
    else
    return_Value = false;
    return return_Value ;
    I hope this will solve ur problem....
    Babu

  • Non numeric value in numeric field giving error

    Hi All
    I am using BAPI for creating sales order. If user is giving non numeric value in Quantity field it is giving error. Because quantity field data type is Double.
    Please Help.
    Thanks
    Raktim

    Hi Banerjee,
                 Create a String/int/long Context variable and point it to UI Input element.Do the validation  for correct input value. once the validation is succesful assign that value to RFC BigDecimal variable by Explicit casting.
    Hope this might solve your problem .
    Thanks
    Madhan

  • At new- command - making non-numeric fields as ******* how to correct this

    Hi,
    I am using the following code.
    Tables : vbap.
    DATA: t_vbap TYPE STANDARD TABLE OF vbap,
          x_vbap TYPE vbap.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-000.
    SELECT-OPTIONS: s_vbeln FOR vbap-vbeln.
    SELECTION-SCREEN END OF BLOCK b1.
    START-OF-SELECTION.
      SELECT * FROM vbap
        INTO TABLE t_vbap
        WHERE vbeln IN s_vbeln.
      LOOP AT t_vbap INTO x_vbap.
        at new vbeln.
          write:'new vbeln'.
          ENDAT.
      ENDLOOP.
    In debugging mode, the non-numeric fields on x_vbap becomes ****
    I want to know whether this can be done using oops.. any methods available for at new
    Moderator message: please search for available information/documentation before asking (as you can tell from some of the replies so far)
    locked by: Thomas Zloch on Oct 1, 2010 3:25 PM

    see documentation:
    "If the INTO addition is used in the LOOP statement to assign the content of the current line to a work area wa, its content is changed upon entry into the AT-ENDAT control structure as follows:
    The components of the current control key remain unchanged.
    All components with a character-type, flat data type to the right of the current control key are set to character "*" in every position.
    All the other components to the right of the current control key are set to their initial value.
    When the AT-ENDAT control structure is exited, the content of the current table line is assigned to the entire work area wa. "

  • Find a non-numeric character in a string

    I have a 3 strings (1) 'AB99CDEFGH0012%' (2) 'ABCDEFGH' (3) 'ABCD11'
    how do i find out a that string has non numeric characters
    Thanks

    SELECT TO_NUMBER(:String) FROM DUAL;
    is a quick way to find out :)
    A good method would be.....
    SELECT 1 FROM DUAL WHERE TRANSLATE(:String, 1234567890, '-') IS NOT NULL;
    The statement will filter out ALL numbers, leaving behind any characters, A, B, @, ~, etc...

  • How do I take two separate non numeric fields in a acrobat form and combine the data to display in a third separate field?

    How do I take two separate non numeric fields in a acrobat form and combine the data to display in a third separate field?

    You have to use custom JavScripting to concatenate the first 2 fields. You cannot use the first 2 calculation options because they force the values of the fields to a numeric value or ignore string values.
    Possible scripts for the 3rd field are:
    event.value = this.getField("Text1").valueAsString + " " + this.getField("Text2").valueAsString;
    or
    event.value = this.getField("Text1").valueAsString.concat( " ",  this.getField("Text2").valueAsString);
    If you do not want change the separator or not show the separator when on or the other field is empty, you will need to add more code to adjust for change.
    The above scripts will also concatenate number because the field values are read as strings and not numbers.
    There is also a generalized user written function to concatenate up to 3 fields with a separator that adjust for missing data.

  • Convert non numeric field

    I'm looking for a function that will allow a conversion from a non-numeric field to a numeric field. Any suggestions?

    CAST(col as INTEGER) or CAST(col as DOUBLE)

  • Numeric and Non Numeric Data

    Hi,
    I have to check the data in Varchar2 field idtr and if it is numeric some actions are to be done on the data and if it is numeric some other different action is to be done.
    So I used some logic for finding whether the data is numeric or non numeric which I got it from the net.
    Now my problem is all decimal numbers are to be treated as numeric but this logic is treating decimals as non numeric and I am not able to proceed further.
    Can some one help me out in this issue.
    Below is the Logic and actions I am doing
    select      pol_id,lpad(substr(trunc(to_number(idtr),0),1,10),10,0),idtr
    from           pl_insrd
    where      length(idtr) - length(translate(idtr,chr(1)||translate(idtr,CHR(1)||'1234567890',CHR(1) ),CHR(1) ) ) = 0
    and           length(idtr) > 9
    UNION
    select      pol_id,lpad(trunc(idtr,0),10,0),idtr
    from           pl_insrd
    where      length(idtr) - length(translate(idtr,chr(1)||translate(idtr,CHR(1)||'1234567890',CHR(1) ),CHR(1) ) ) = 0
    and           length(idtr) < 10
    UNION
    select      pol_id,substr(idtr,1,10),idtr
    from           pl_insrd
    where      length(idtr) - Length(TRANSLATE(idtr,CHR(1)||TRANSLATE(idtr,CHR(1)||'1234567890', CHR(1) ), CHR(1) ) ) > 0
    and           length(idtr) > 9
    UNION
    select      pol_id,lpad(idtr,10,0),idtr
    from      pl_insrd
    where      length(idtr) - Length(TRANSLATE(idtr,CHR(1)||TRANSLATE(idtr,CHR(1)||'1234567890', CHR(1) ), CHR(1) ) ) > 0
    and           length(idtr) < 10

    <quote>One I provided was I found at asktom.oracle.com</quote>
    So? ... If you'd provided a link then one could see the entire context for that particular snippet of code and decide if it is indeed appropriate. As shown by Angus it is not always appropriate ... add to that, NULL is not a number as that function reports.
    <quote>It's using replace and transalate functions which are less expensive then To_Number function.</quote>
    Proof?
    <quote>I agree with you [John], that's the best function you can use to validate data for numeric.<quote>
    I don't agree to_number() is [always] the best way ... the easiest way? ... maybe.
    My personal view is that there is no universal way to determine if a string, in all circumstances, can be translated into a number. One has to have knowledge of the source data domain ... only you know if, in your particular circumstance, '1e4' is or is not a NUMBER represented as a string.
    flip@FLOP> select to_number('1e3') from dual;
    TO_NUMBER('1E3')
    1000

  • Non numeric @Id being treated as numeric (EJB3/ADF Faces) [Please Frank]

    Hi,
    I have a non-numeric field (varchar2) defined as such:
    public class DepartmentV implements Serializable {
        @Id
        @Column(name="DEPT_ID", nullable = false)
        private String deptId;
    ...When I run the program, I get the following error:
    Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2006.8 (Build 060829)): oracle.toplink.essentials.exceptions.DatabaseException
    Internal Exception: java.sql.SQLException: ORA-01722: invalid numberThis is because the column in the table has some non-numerics in it. However the column is defined as varchar, and in the EJB it is defined as String, so why is it being treated as a numeric and how do I fix it?
    many thanks
    R

    Hi,
    tried to reproduce in JDeveloper 10.1.3.2 with no success
    @Entity
    @NamedQuery(name = "Testtable.findAll", query = "select o from Testtable o")
    public class Testtable implements Serializable {
    private Long age;
    @Id
    @Column(nullable = false)
    private String idf;
    private String name;
    public Testtable() {
    public Long getAge() {
    return age;
    public void setAge(Long age) {
    this.age = age;
    public String getIdf() {
    return idf;
    public void setIdf(String idf) {
    this.idf = idf;
    public String getName() {
    return name;
    public void setName(String name) {
    this.name = name;
    Works as designed
    Frabj

  • Error while pulling data from an Oracle database. ORA-01858: a non-numeric character was found where a numeric was expected

    I'm trying to pull data from an Oracle database using SSIS. When I try to select a few fields from the source table, it returns the following error message:
        [OLE DB Source [47]] Error: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80040E14.
        An OLE DB record is available.  Source: "OraOLEDB"  Hresult: 0x80040E14  Description: "ORA-01858: a non-numeric character was found where a numeric was expected".
        An OLE DB record is available.  Source: "OraOLEDB"  Hresult: 0x80004005  Description: "ORA-01858: a non-numeric character was found where a numeric was expected".
    The source columns are a combination of numeric and texts, and I've also tried selecting one of them, which didn't work. I'm using the Oracle client 11.2.0.1, and it works fine with any other data sources I have connected to so far. How can I resolve this
    error?

    Hi H.James,
    According to your description, the issue is a non-numeric character was found where a numeric was expected while pulling data from an Oracle database in SSIS.
    Based on the error message, the issue should be you are comparing a number column to a non-number column in a query. Such as the query below (ConfID is a number, Sdate is a date):
     where C.ConfID in (select C.Sdate
                       from Conference_C C
                       where C.Sdate < '1-July-12')
    Besides, a default behavior for the Oracle OleDb Provider that change the NLS Date Format of the session to 'YYYY-MM-DD HH24:MI:SS can also cause the issue. For more details about this issue, please refer to the following blog:
    http://blogs.msdn.com/b/dataaccesstechnologies/archive/2012/01/20/every-bug-is-a-microsoft-bug-until-proven-otherwise.aspx
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Best practice to define length for varchar field of table in sql server

    What is best practice to define length for a varchar field in table
    where field suppose Remarks By Person  varchar(max) or varchar(4000)
    Could it affect on optimization in future????
    experts Reply Must ... 
    Dilip Patil..

    Hi Dilip,
    Varchar(n/max) is a variable-length, non-unicode character data. N defines the string length and can be a value from 1 through 8,000. Max indicates that the maximum storage size is 2^31-1 bytes (2 GB). The storage size is the actual length of the data entered
    + 2 bytes. We always use varchar when the sizes of the column data entries vary considerably. While if the filed data size might exceed 8,000 bytes in some way, we should use varchar(max).
    So the conclusion is just like Uri said, use varchar(max) or varchar(4000) is depends on how much characters we are going to store.
    The following document about varchar in SQL Server is for your reference:
    http://technet.microsoft.com/en-us/library/ms176089.aspx
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Check for non-numeric characters in textbox input

    I have a form with several textboxes, each of which can accept numeric input. I want to write a validation/ plsql block that checks for a non-numeric character in the input, so that my user sees a customized error message rather than a database error. Any tips on how I can achieve that? Is there any function like "isalpha" in C, which can directly do the job?
    Also, some of these numeric fields should allow commas, since people put commas in larger numbers.
    Any help is greatly appreciated.

    Arie,
    i figured it out. turns out, i had some confusion in my mind. i modified Taneal's solution to use it in my already existing validations of type 'function returning error text' and it works fine.
    the problem before was that i was running 2 separate validations on the same field, and probably due to the sequence numbers, i was getting a numeric or value error. now, i've combined all validations into a single validation and it works fine.
    and honestly, i'm pretty bad with reg. ex. :D

  • How can I remove non-numeric characters from a cell?

    I have a file an rtf file that I can open in Numbers. It puts each line in a separate cell. Each cell contains non-numeric and numeric characters. I'd like to delete the non-numeric characters so that I can add the numbers together. Is there a way to do this easily in Numbers that doesn't require doing it manually?
    Thanks,
    David

    Ok, David,
    This solution will work for vlaues up to 99,000 and if there is a space in front of your amount. There are two parts for clarity but you could wrap them up into one formula if you wanted to.
    B2 =FIND(" ",A2,LEN(A2)−9)
    C2 =MID(A2,B2,10)
    If there is a return before your amount (certain cells in your screenshot got me wondering) then the formula in column B
    =FIND("
    ",A2,1)
    It looks funny because it is finding the return.
    Let me know if this works for you.
    quinn

Maybe you are looking for

  • Flash 8 + AOL = Problems

    Hey All, I've learned it's best to do as much research as you can before posting on these forums, and that's exactly what I've done. So, I now turn to you all as a last resort (and from the handful of posts I've seen regarding problems with the AOL b

  • Assign error with complex type return message

    Dear all, I have an axis web service with complex type return message. When I invoke the web service, and try to assign one element of the result to other variable, it fails with following error message(BPEL Fault:{http://schemas.xmlsoap.org/ws/2003/

  • Incoming email configurations, what is missing?

    I have configured incoming email settings in CA (System > Incoming email) and created SMTP service in Server Manager. I have also checked settings in IIS Manager > SMTP Virtual Server and set Properties > Access > Relay: Granted Access for IP address

  • Automator not working after upgrade to Yosemite

    I created a fairly simple Folder Action within Automator in Mavericks that went like this; 1) Receive file in Folder e.g Folder 1 2) Move file from Folder 1 to Folder 2 3) Label file Red Now I cannot get anything to work in Automator since upgrading

  • Side by side configuration issue

    Hi - New to all this but here goes.....downloaded media go, when i come to use it i get an error message telling me that "application has failed to start because its side by side configuration is incorrect". Any ideas what i can do to resolve this. J