Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Update Statement to Remove "White Spaces"

User_OMEF8Aug 14 2014 — edited Aug 18 2014

Database:  Oracle 11.2.0.1.0

In the database, we have values in columns that contain "white spaces" some times before and/or after the value.  What is the best procedure to remove these extra white spaces?  I have provided examples below.

AccountNumberInvoiceNumber
     123     INV-123
456     INV-456    
     789    

     INV-456    

123     456INV    123456

Row 1, has 5 white spaces before the value.

Row 2, has 5 white spaces after the value

Row 3, has 5 white spaces before and after the value

Row 4, has 5 white spaces between the value <==== this one is okay

Essentially, I would want to trim the LEFT and RIGHT side only.  Every thing in between does not seem to be an issue at this moment.  Is the below query the best procedure to handle the removal?

update table1

set AccountNumber = trim(AccountNumber);

This post has been answered by Frank Kulash on Aug 15 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 15 2014
Added on Aug 14 2014
3 comments
2,484 views