Solved

Space inserted when Incrementing a number

Posted on 2008-10-05
6
206 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
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 Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
This video shows how to recover a database from a user managed backup

770 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