Solved

Space inserted when Incrementing a number

Posted on 2008-10-05
6
208 Views
Last Modified: 2013-12-19
Hi I am trying to update a field which has  a fomat of '00000'.

When I update using this code:

a.version      = TO_CHAR( a.version + 1, '00000')

I am getting for instance ' 00001'. Please note the space before the zeros.

Any help please?
Thanks.
0
Comment
Question by:Rassac
  • 3
  • 3
6 Comments
 

Author Comment

by:Rassac
ID: 22647299
I managed to solve the problem by using Trim

a.version      = Trim(TO_CHAR( a.version + 1, '00000'))

Is there any explanation for this, why is a space being inserted?

Thanks.
0
 
LVL 6

Expert Comment

by:carlsiy
ID: 22648675
- check the actual value of a.version what is its exact length or data type?
0
 

Author Comment

by:Rassac
ID: 22648695
It's varchar2(10)
0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
LVL 6

Accepted Solution

by:
carlsiy earned 500 total points
ID: 22648740
it could be because of the default field length of the varchar2(10). it may result that you only formatted the string only 5 chars right of the actual data.
0
 

Author Comment

by:Rassac
ID: 22648756
So how would you go around it? Is it necessary to use the trim or maybe some other code could be used?

thanks.
0
 
LVL 6

Expert Comment

by:carlsiy
ID: 22648770
the code you used just about sums it up.
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question