?
Solved

Space inserted when Incrementing a number

Posted on 2008-10-05
6
Medium Priority
?
213 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 6

Accepted Solution

by:
carlsiy earned 2000 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

Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

Question has a verified solution.

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

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…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
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…
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.
Suggested Courses

762 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