zoukankan      html  css  js  c++  java
  • 查出数字字符字段中非数字字符的记录

    最近,将原来的数字符字段转换为数字时,总报错误:无效数字。

    如何找出其中哪些是非数字字符的记录?比较麻烦的事。下面是用Oracle DB自带的函数translate可以找出来的

    1.创建测试表

    Create Table TestChar(
        ITEM_NUMBER VARCHAR2(20)
    );

    2.手工插入测试记录

    Insert Into TestChar (ITEM_NUMBER) values ('312');
    Insert Into TestChar (ITEM_NUMBER) values ('312');
    Insert Into TestChar (ITEM_NUMBER) values ('4412');
    Insert Into TestChar (ITEM_NUMBER) values ('152');
    Insert Into TestChar (ITEM_NUMBER) values ('162');
    Insert Into TestChar (ITEM_NUMBER) values ('172');
    Insert Into TestChar (ITEM_NUMBER) values ('142');
    Insert Into TestChar (ITEM_NUMBER) values ('142');
    Insert Into TestChar (ITEM_NUMBER) values ('112');
    Insert Into TestChar (ITEM_NUMBER) values ('1d2');
    Insert Into TestChar (ITEM_NUMBER) values ('152');
    Insert Into TestChar (ITEM_NUMBER) values ('125');
    Insert Into TestChar (ITEM_NUMBER) values ('162');
    Insert Into TestChar (ITEM_NUMBER) values ('712');
    Insert Into TestChar (ITEM_NUMBER) values ('A712');
    commit;

    3.妙用Oracle 内置函数Translate找出非数字字符的记录

    select trim(translate(RTRIM(LTRIM(ITEM_NUMBER)), '#0123456789', '#'))
      from TestChar
     Where trim(translate(RTRIM(LTRIM(ITEM_NUMBER)), '#0123456789', '#')) is not null;

  • 相关阅读:
    JavaScipt
    实例应用,做了一个网页
    css 层叠式样式表(3)
    css 层叠式样式表(2)
    css 层叠式样式表(1)
    HTML 框架
    .NET回归 HTML----表单元素(1)和一些常用的标记
    .NET回归 HTML----超文本标记语言(暂时无图)
    排序算法: 选择排序法
    排序算法:快速排序法
  • 原文地址:https://www.cnblogs.com/zzjhn/p/5130999.html
Copyright © 2011-2022 走看看