Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Removing extra spaces in a field.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
mprabu

New User


Joined: 29 Jul 2006
Posts: 2

PostPosted: Tue Aug 01, 2006 8:37 pm    Post subject: Removing extra spaces in a field.
Reply with quote

I have a query where data selected from table A is inserted into table B.
I want the extra spaces to be removed in one of the fields of Table A
and then inserted to table B.
Ex: 'ram and co '

should be 'ram and co'

Can this be done in the query using some functions or any logic.
Please help me.
Back to top
View user's profile Send private message

DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Tue Aug 01, 2006 10:42 pm    Post subject: Re: Removing extra spaces in a field.
Reply with quote

What is the definition of the columns you are moving from and to?

Dave
Back to top
View user's profile Send private message
chiranjeevi_mca

New User


Joined: 19 Feb 2006
Posts: 27

PostPosted: Wed Aug 02, 2006 10:08 am    Post subject:
Reply with quote

LTRIM(RTRIM(COL1))
Back to top
View user's profile Send private message
mprabu

New User


Joined: 29 Jul 2006
Posts: 2

PostPosted: Wed Aug 02, 2006 11:42 am    Post subject: Re: Removing extra spaces in a field.
Reply with quote

The field is a Character of length 80.
The extra spaces i meant also include the spaces between the words.
i.e. The field can have many words but with only one space separating them.
Thanks for all your replies and this would be a Great help to me.
Back to top
View user's profile Send private message
parikshit123

Active User


Joined: 01 Jul 2005
Posts: 269
Location: India

PostPosted: Fri Aug 11, 2006 12:48 pm    Post subject:
Reply with quote

Hi,
I think that there should be a function TRIM(fied_name) in DB2. If not, you can use RTRIM(LTRIM(variable)) to achieve the same.
Back to top
View user's profile Send private message
renjith
Warnings : 1

New User


Joined: 07 Aug 2006
Posts: 11

PostPosted: Fri Aug 11, 2006 1:35 pm    Post subject: Re: Removing extra spaces in a field.
Reply with quote

I dont think taht TRIM() is a DB2 function.To achieve this u can use

SELECT STRIP(col1) FROM owner.table




thanks
renjith
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts INVALID FIELD OR CONSTANT IN SORTOF ?? Ron Klop DFSORT/ICETOOL 8 Wed Jan 11, 2017 3:44 pm
No new posts Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am
No new posts Performing arithmetic on input field zh_lad DFSORT/ICETOOL 31 Tue Dec 06, 2016 8:04 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us