如何查找CHAR字符串的实际LENGTH [英] How to find actual LENGTH of a CHAR string

查看:86
本文介绍了如何查找CHAR字符串的实际LENGTH的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在Windows XP平台上使用DB2 8.2版。


我有一个表''EMP'',其中一个字段名为' CHAR的'NAME',大小

80.


另外,我有NAME =''john'的记录


现在,当我尝试查找此名称字段的长度时,DB2返回

80。有人能告诉我如何在不使用RTRIM的情况下找到这个NAME

字段值(''john'')的实际长度。


我说没有使用RTRIM因为,我希望能够找到

长度的char字符串,比如''john''。

提前谢谢

mailar

Hi,
I am using DB2 version 8.2 on Windows XP platform.

I have a table ''EMP'' with one field named ''NAME'' of type CHAR , size
80.

Also , I have a record with NAME=''john''

Now, when I try to find the length of the this name field DB2 returns
80 . Can someone tell me how do I find the actual length of this NAME
field value (''john'') without making use of RTRIM.

I say without using RTRIM because, I want to be able to find out the
length of char strings like '' john '' as well .
Thanks in advance
mailar

推荐答案

文章< 11 ************** *******@c13g2000cwb.googlegroups。 com>,

(mament@gmail.com)说...
In article <11*********************@c13g2000cwb.googlegroups. com>,
(ma****@gmail.com) says...

我在Windows XP平台上使用DB2版本8.2 。

我有一个表''EMP'',其中一个字段名为''NAME'',类型为CHAR,大小为80.

另外,我有NAME =''john'的记录

现在,当我试图找到这个名字字段的长度时,DB2返回了80。有人可以告诉我如何在不使用RTRIM的情况下找到这个NAME
字段值(''john'')的实际长度。

我说不使用RTRIM因为,我想要能够找到像''john'这样的字符串的长度。
提前致谢
mailar
Hi,
I am using DB2 version 8.2 on Windows XP platform.

I have a table ''EMP'' with one field named ''NAME'' of type CHAR , size
80.

Also , I have a record with NAME=''john''

Now, when I try to find the length of the this name field DB2 returns
80 . Can someone tell me how do I find the actual length of this NAME
field value (''john'') without making use of RTRIM.

I say without using RTRIM because, I want to be able to find out the
length of char strings like '' john '' as well .
Thanks in advance
mailar




你可以把它变成varchar或用特殊字符填充列的剩余部分




You could make it a varchar or fill the remaining part of the column
with a special character.




我不想把它变成一个VARCHAR字段。


另外,如果我填写其余部分我的应用程序没有意义

包含其他一些字符。


有没有办法可以弄清楚用户有什么价值

在列中输入并知道这个值的长度没有

,包括DB2填充的剩余空格。

Hi,
I do not want to make it a VARCHAR field.

Also , my application does not make sense if I fill the remaining part
with some other characters.

Is there a way by which I can figure out what value the user has
entered in the column and know the length of this value without
including the remaining white spaces padded by DB2.


文章< 11 **** ******************@z14g2000cwz.googleg roups .com>,

(maRS@gmail.com)说......
In article <11**********************@z14g2000cwz.googlegroups .com>,
(ma****@gmail.com) says...

我不想让它成为一个VARCHAR字段。

另外,如果我用其他一些字符填充剩下的部分,我的应用程序没有意义。


在使用原始数据之前你不能剥离它们吗?

有没有办法让我弄清楚它的价值是什么用户已经在列中输入并知道该值的长度,而不包括由DB2填充的剩余空格。
Hi,
I do not want to make it a VARCHAR field.

Also , my application does not make sense if I fill the remaining part
with some other characters.
You can''t strip them before ''using'' the original data?
Is there a way by which I can figure out what value the user has
entered in the column and know the length of this value without
including the remaining white spaces padded by DB2.




如果你没有不想把它改成varchar。也许添加一个包含原始长度的栏目

会有帮助吗?



Not if you don''t want to change it to varchar. Maybe adding a column
containing the original length will help?


这篇关于如何查找CHAR字符串的实际LENGTH的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆