View previous topic :: View next topic |
Author |
Message |
vkphani Intermediate

Joined: 05 Sep 2003 Posts: 483 Topics: 48
|
Posted: Fri Jul 22, 2005 1:44 am Post subject: How to find length of a varchar string... |
|
|
Hi,
Is there any function to find out a length of a varchar string...
Thanks in advance. |
|
Back to top |
|
 |
Brian Beginner
Joined: 12 Aug 2003 Posts: 95 Topics: 6
|
Posted: Fri Jul 22, 2005 3:16 am Post subject: |
|
|
Paneendra,
Why dont you try writing one of your own. You can look at the INSPECT verb for motivation.
Cheers
Brian |
|
Back to top |
|
 |
vkphani Intermediate

Joined: 05 Sep 2003 Posts: 483 Topics: 48
|
Posted: Fri Jul 22, 2005 3:20 am Post subject: |
|
|
Brian,
I need a function like LENGTH(...) to find out the length. |
|
Back to top |
|
 |
nadh Intermediate
Joined: 08 Oct 2004 Posts: 192 Topics: 89
|
Posted: Fri Jul 22, 2005 4:56 am Post subject: |
|
|
Hi,
There is a function to find out the length, but it is not working exactly for all the inputs. So we used the following code to finding the length for varchar. See whether it will be useful for you.
MOVE FUNCTION REVERSE(O-XDONGEN-TEXT-T) TO XDONGEN1
INSPECT XDONGEN1 TALLYING COUNT1 FOR LEADING SPACES
COMPUTE L1 = LENGTH OF XDONGEN1 - COUNT1
here O-XDONGEN-TEXT-T is the varchar. first you reverse it thru reverse function.
using inspect you will get the leading spaces count into xdongen1. finaly the length
will be in l1 by caliculating length of xdongen1 minus count1.
this method worked exactly for all types of inputs.
cheers!!
Nadh |
|
Back to top |
|
 |
slade Intermediate
Joined: 07 Feb 2003 Posts: 266 Topics: 1 Location: Edison, NJ USA
|
Posted: Sun Jul 24, 2005 9:45 pm Post subject: |
|
|
Hi Nadh,
You don't need the move:
INSPECT FUNCTION REVERSE(TEXT1) TALLYING L FOR LEADING SPACES
works and doesn't change the value of TEXT1. _________________ Regards, Jack.
"A problem well stated is a problem half solved" -- Charles F. Kettering |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
|
Back to top |
|
 |
|
|