IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Removing extra spaces in a field.


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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
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
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
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts leading spaces can be removed in trai... DFSORT/ICETOOL 1
No new posts Join 2 files according to one key field. JCL & VSAM 3
No new posts Cobol program with sequence number ra... COBOL Programming 5
No new posts How to move the first field of each r... DFSORT/ICETOOL 5
Search our Forums:

Back to Top