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 SORT VSAM file with each field one by... maxsubrat DFSORT/ICETOOL 6 Tue Mar 14, 2017 1:07 pm
No new posts IMS DB-How to update a record (a sing... Nic Clouston IMS DB/DC 9 Thu Mar 09, 2017 4:38 pm
No new posts outrec field outside range Danielle.Filteau SYNCSORT 10 Sat Mar 04, 2017 2:37 am
No new posts 2 byte YEAR from Y'DATE2' field tecnokrat DFSORT/ICETOOL 2 Tue Feb 07, 2017 12:05 pm
No new posts Count Trailing Spaces in variable str... Virendra Shambharkar SYNCSORT 10 Thu Feb 02, 2017 12:23 pm


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