oracle dump的使用心得

系统 1357 0

  使用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来做填充空格的操作。

 

oracle dump的使用心得


更多文章、技术交流、商务合作、联系博主

微信扫码或搜索:z360901061

微信扫一扫加我为好友

QQ号联系: 360901061

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描下面二维码支持博主2元、5元、10元、20元等您想捐的金额吧,狠狠点击下面给点支持吧,站长非常感激您!手机微信长按不能支付解决办法:请将微信支付二维码保存到相册,切换到微信,然后点击微信右上角扫一扫功能,选择支付二维码完成支付。

【本文对您有帮助就好】

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描上面二维码支持博主2元、5元、10元、自定义金额等您想捐的金额吧,站长会非常 感谢您的哦!!!

发表我的评论
最新评论 总共0条评论