Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 Removing the period or dot from the v... gopinak COBOL Programming 6 Wed May 09, 2018 1:53 pm
No new posts How to include a particular field val... sakrat DFSORT/ICETOOL 8 Fri Apr 06, 2018 8:27 pm
No new posts Sort numeric fields with trailing spaces sancraig16 SYNCSORT 7 Tue Apr 03, 2018 1:21 am
No new posts Extract the records with a PD field's... sudhakar84 DFSORT/ICETOOL 11 Mon Apr 02, 2018 7:26 pm
No new posts Searching a table for the field name? socker_dad COBOL Programming 8 Sat Mar 31, 2018 2:57 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us