zoukankan      html  css  js  c++  java
  • oracle dump的使用心得

      使用DS开发的时候,有的时候会遇到一个问题:数据库层面定义的空格与DS自已定义的空格概念不一致,导致生成的数据会有一定的问题.

      举例来说:

      在数据库里面定义CHAR(20),如果插入的字符不足20的时候,会自动补空格(ascii为0x20);在DS里面的话,源数据如果不满足20的话,那么DS也会自动补全,此时补的值为ascii 0x00。那么,这条记录在数据库里面的话,表面上是看不出异常的,但是加条件查询的时候,是查不出来结果集的。此时,就要用到dump来判断是否有此类情况出现。

          oracle的dump函数就不介绍了,需要用到的时候,请google即可。

    The argument return_fmt specifies the format of the return value and can have any of the following values:

    • 8 returns result in octal notation.

    • 10 returns result in decimal notation.

    • 16 returns result in hexadecimal notation.

    • 17 returns each byte printed as a character if and only if it can be interpreted as a printable character in the character set of the compiler—typically ASCII or EBCDIC. Some ASCII control characters may be printed in the form ^X as well. Otherwise the character is printed in hexidecimal notation. All NLS parameters are ignored. Do not depend on any particular output format for DUMP with return_fmt 17.

    By default, the return value contains no character set information. To retrieve the character set name of expr, add 1000 to any of the preceding format values. For example, a return_fmt of 1008 returns the result in octal and provides the character set name of expr.

    The arguments start_position and length combine to determine which portion of the internal representation to return. The default is to return the entire internal representation in decimal notation.

    If expr is null, then this function returns NULL.

    select dump(test_col) from test_tb;

    Typ=96 Len=15: 54,52,54,53,51,49,57,32,32,32,32,32,32,0,0

    typ表示当前的expr值的类型。如:2表示NUMBER,96表示CHAR。然后长度就是15位,最后二位就是ascii 0.

    那么,这个时候查询这条记录是没办法查询出来的。

    select * from test_tb where trim(replace(test_col,chr(0),''))='6465319'  --按此查询即可得出结果。

    PS:一般遇到这种情况,最好的办法是在DS的定义里面把char改成varchar,让DB来做填充空格的操作。

  • 相关阅读:
    CentOS7 运维
    【推荐】开源项目ElasticAmbari助力 ElasticSearch、Kibana、ambari服务高效运维管理
    逆向工程,调试Hello World !程序(更新中)
    校园网内网穿透
    搭建PXE服务及实现安装银河麒麟桌面操作系统
    Linux 的基础知识关于基本操作命令 --- No.3
    Unix/Linux fork前传
    60行C代码实现一个shell
    Linux 的基础知识回顾(安装vmware) ---- No.1 后面都以Centos8 为例
    vue v-bind绑定属性和样式
  • 原文地址:https://www.cnblogs.com/gobird/p/3629293.html
Copyright © 2011-2022 走看看