Oracle determines whether it is a numeric or numeric string (sqlserver isnumeric)

Source: Internet
Author: User

 

Requirements:

If the field value is not a numeric or numeric string, update the field value''

1. Function Method (batch release is not allowed ):

create   or   replace   function   isNumber(p_in   varchar2)   return   boolean   as         i   number; begin         i:=to_number(p_in);         return   true; exception               when   others   then                 return   false; end   ; 

However, it seems that this can only be judged one by one and cannot be performed in batches.

2.

SQL> select   nvl2(translate('333', '\1234567890 ', '\'), 'is   characters ', 'is   number ')   from   dual;NVL2(TRANSLATE('333','\1234567------------------------------is   numberSQL> select   nvl2(translate(333, '\1234567890 ', '\'), 'is   characters', 'is   number')   from   dual;NVL2(TRANSLATE(333,'\123456789------------------------------is   numberSQL> select   nvl2(translate('aaaaa', '\1234567890 ', '\'), 'is   characters', 'is   number')   from   dual;NVL2(TRANSLATE('AAAAA','\12345------------------------------is   charactersSQL> 

3. It is said that batch query is required. You can check it out first, but you have not tried it:

select   decode(nvl2(translate(column, '\1234567890 ', '\'), '0', '1') ,'1',column,'')  from   dual;

I wrote:

Update T_87_Mtbuf Set SpCode='' Where  nvl2(translate(SpCode, '\1234567890 ', '\'), 'is   characters', 'is   number ')='is   characters';

Add:

To_number (...) can only accept numbers such as 122 or numeric string '123456'. If 'aaa' is accepted, an error "invalid character" is returned ".
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.