Solved

Space inserted when Incrementing a number

Posted on 2008-10-05
6
203 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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

705 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now