Translate to your Language

Disclaimer Statement

Total Pageviews

47,463

Track

Follow us on FaceBook

About

Powered by Blogger.

Popular Posts

Tuesday, December 10, 2013

Netezza ISNUMERIC Data Check Logic

by Unknown  |  in DB at  2:33 AM

Netezza dosen't have any isnumeric check function, so in order to find out whether the column has non-numeric, use the following logic

nvl(instr(translate(Column_Name,
        'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'),'X'),0)

if the column has non numeric then it will return 1 else it will be 0, I haven't included the special characters in the logic, if you have '%,$,£..' then include them in the translate part and it will work



One of our visitor posted the following method

istrue(length(translate(Column_Name,'0123456789',''))=0) as isnumeric

If the resulting length is zero then it is numeric, or the string was empty. If the latter is a possibility then you could add another check

istrue(length(translate(Column_Name,'0123456789',''))=0 and length(Column_Name)>0) as isnumeric

Related Posts

6 comments:

  1. Thanks! exactly what i was looking for. Works perfect.

    ReplyDelete
  2. Flipping Dinix's function on it's head we can remove the numbers instead and then count what's left.

    istrue(length(translate(Column_Name,'0123456789',''))=0) as isnumeric

    If the resulting length is zero then it is numeric, or the string was empty. If the latter is a possibility then you could add another check

    istrue(length(translate(Column_Name,'0123456789',''))=0 and length(Column_Name)>0) as isnumeric

    This way you do not need to worry about which special characters to include.

    ReplyDelete
  3. This is good one, I will update my post with it

    ReplyDelete
  4. How about using one of the Regular Expression functions as follows:
    WHERE NOT REGEXP_LIKE(FIELDTOCHK,'[0-9]')

    Or wrapping it into a case statement:
    CASE WHEN NOT REGEXP_LIKE(FIELDTOCHK,'[0-9]') THEN 0 ELSE 1 END AS ISNUMERIC

    ReplyDelete
    Replies
    1. You may want to strip out full stops, commas, currency signs, etc. before doing this. You can use REGEXP_REPLACE to do that.

      Delete

© Copyright © 2014Bigdata-dwbi. by Bloggertheme9