• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 217
  • Last Modified:

Space inserted when Incrementing a number

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
Rassac
Asked:
Rassac
  • 3
  • 3
1 Solution
 
RassacAuthor Commented:
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
 
carlsiyCommented:
- check the actual value of a.version what is its exact length or data type?
0
 
RassacAuthor Commented:
It's varchar2(10)
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
carlsiyCommented:
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
 
RassacAuthor Commented:
So how would you go around it? Is it necessary to use the trim or maybe some other code could be used?

thanks.
0
 
carlsiyCommented:
the code you used just about sums it up.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now