View previous topic :: View next topic |
Author |
Message |
AshStar Beginner
Joined: 25 Jan 2007 Posts: 4 Topics: 1
|
Posted: Tue Feb 13, 2007 11:08 pm Post subject: conversions from Alphanumeric to smallint with left justifie |
|
|
hi we get a set of records in the file and they got to updated in the table the value we receive from the file is Alphanumeric but the corresponding values in the table is small int for some cases and numeric in other cases.
now i need to updated the records in the table and they need to left justified how to acheive this???// Please help.... |
|
Back to top |
|
 |
programmer1 Beginner
Joined: 18 Feb 2004 Posts: 138 Topics: 14
|
Posted: Tue Feb 13, 2007 11:15 pm Post subject: |
|
|
Why can't you simply move this alphanumeric value into the host variable declared for your table column and update the table? _________________ Regards,
Programmer |
|
Back to top |
|
 |
AshStar Beginner
Joined: 25 Jan 2007 Posts: 4 Topics: 1
|
Posted: Wed Feb 14, 2007 12:52 am Post subject: |
|
|
No since we got to left justify the values we cant move it directly for instance if the value is spaceXspace or spacespaceX it should be moved as X only..... |
|
Back to top |
|
 |
hareshh Beginner
Joined: 13 Dec 2006 Posts: 16 Topics: 0
|
|
Back to top |
|
 |
shekar123 Advanced
Joined: 22 Jul 2005 Posts: 528 Topics: 90 Location: Bangalore India
|
|
Back to top |
|
 |
hareshh Beginner
Joined: 13 Dec 2006 Posts: 16 Topics: 0
|
Posted: Wed Feb 14, 2007 1:49 am Post subject: |
|
|
Hi AshStar,
I think NUMVAL will make it right justify but you need Left justify so we can do this as shown-
A X(10)
B 9(10)
J = 1
PERFORM VARYING I FROM 1 BY 1 UNTIL I > 10
IF A(I:1) EQUAL SPACES
CONTINUE
ELSE
MOVE(I:1) TO B(J:1)
ADD +1 TO J
END-IF
END-PERFORM
Regards,
Haresh. |
|
Back to top |
|
 |
hareshh Beginner
Joined: 13 Dec 2006 Posts: 16 Topics: 0
|
Posted: Wed Feb 14, 2007 1:52 am Post subject: |
|
|
Cool Shekar boss is taking you to the right link  |
|
Back to top |
|
 |
AshStar Beginner
Joined: 25 Jan 2007 Posts: 4 Topics: 1
|
Posted: Wed Feb 14, 2007 3:16 am Post subject: |
|
|
hi thanks a lot...
Is it possible to acccompolish this using sort? |
|
Back to top |
|
 |
AshStar Beginner
Joined: 25 Jan 2007 Posts: 4 Topics: 1
|
Posted: Wed Feb 14, 2007 3:24 am Post subject: |
|
|
hi
one more question... if my value is "003" will the NUMVAL function truncate the preceding zeroes and the provide the value is "3".... |
|
Back to top |
|
 |
hareshh Beginner
Joined: 13 Dec 2006 Posts: 16 Topics: 0
|
Posted: Wed Feb 14, 2007 4:00 am Post subject: |
|
|
Quote: |
if my value is "003" will the NUMVAL function truncate the preceding zeroes and the provide the value is "3"
|
Hi AshStar,
Yes. Please check the document link provided in my previous post there is example of '+001.23' it is simillar to what you are looking for.
Regards,
Haresh.  |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Wed Feb 14, 2007 6:56 am Post subject: |
|
|
AshStar,
Woah. Just read the whole thread and you are just complicating a simple issue.
Use NUM-VAL function and you are all set , you don't have to worry about removing leading zeros.If your db2 table columns are defined as Decimal or integer they will automatically converted to their respective format.
What do you need sort for ?
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
|
|