473,568 Members | 2,939 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

translate function

Hi all,

I am trying to remove all blank chars in middle of the string "text1
text2 text3 text3 text4"

with following stmt:

VALUES(translat e('text1 text2 text3 text3 text4' , ''
,' ' ))

But it seems that the resulting string same with the input string.

1
-------------------------------------
text1 text2 text3 text3 text4

1 record(s) selected.
Do you have any idea what is going on here?

FYI:

VALUES(translat e('text1 text2 text3 text3 text4' , '*'
,' ' )) produces the

right output

1
-------------------------------------
text1**text2*** text3******text 3*text4

1 record(s) selected.

Regards,

Mehmet Baserdem

May 30 '06 #1
3 12382
Hello.
Try this:
--
VALUES(replace( 'text1 text2 text3 text3 text4' , ' ' ,''
))
--

Sincerely,
Mark B.
I am trying to remove all blank chars in middle of the string "text1
text2 text3 text3 text4"

with following stmt:

VALUES(translat e('text1 text2 text3 text3 text4' , ''
,' ' ))


May 31 '06 #2
Mehmet,
If trimming of white spaces is what is really intented, then replace is
the function you want to use.
Translate: Returns a transformed string expression & thus the length of
the return'd string would be same as the original.
Replace: replaces all the occurrences of expr1 in expr2 with expr3

For example:
DB2-CLP Prompt>db2 values "char(replace(' text1 text2 text3
text3 text4',' ',''),25)"

1
-------------------------
text1text2text3 text3text4

1 record(s) selected.

Mehmet Baserdem wrote:
Hi all,

I am trying to remove all blank chars in middle of the string "text1
text2 text3 text3 text4"

with following stmt:

VALUES(translat e('text1 text2 text3 text3 text4' , ''
,' ' ))

But it seems that the resulting string same with the input string.

1
-------------------------------------
text1 text2 text3 text3 text4

1 record(s) selected.
Do you have any idea what is going on here?

FYI:

VALUES(translat e('text1 text2 text3 text3 text4' , '*'
,' ' )) produces the

right output

1
-------------------------------------
text1**text2*** text3******text 3*text4

1 record(s) selected.

Regards,

Mehmet Baserdem


May 31 '06 #3
Thanks Mark and Peri,

I was trying to trim the intermediate space chars. It seems that
"Replace: function is getting the job done.

Regards,

Mehmet Baserdem

May 31 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
11157
by: Joe | last post by:
Hi all Is there a TSQL function like Oracle's Translate function? Where: Translate('13,000 Miles','abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ, ',' ') would return '13000'? I'm trying to extract a number from a string. REPLACE doesn't quite do what I want.
5
3928
by: Tim Marshall | last post by:
Hi folks, I'm using a web page I've found as a reference to some pet project I'm working on in Access and I'm having trouble "translating" some of the procedures to VBA. I think the stuff is in some version of C (of which I know nothing about) and I would really appreciate it if someone might be able to explain some of these operators to...
1
2523
by: kennethfine | last post by:
I'm transitioning from ASP development, please excuse these basic questions. One thing I did often in ASP was create a "translate" function to render one string to another, strip out excess carriage returns, etc. I want to do the same thing in ASP.NET. I have a mail component that will accept HTML, but it requires all HTML to be listed on...
6
2751
by: bobueland | last post by:
The module string has a function called translate. I tried to find the source code for that function. In: C:\Python24\Lib there is one file called string.py I open it and it says
2
1513
by: johkar | last post by:
I have a rather long unbroke string (a URL) which I would like to break at certain points using XSL. I can't seem to get translate() to work: translate(.,'/',,'&lt;wbr>/&lt;/wbr>') I don't know that the <wbr> tag is valid, but if can stick something within the string I think I can figure out a way for it to wrap.
9
3091
bvdet
by: bvdet | last post by:
I have done some more work on a simple class I wrote to calculate a global coordinate in 3D given a local coordinate: ## Basis3D.py Version 1.02 (module macrolib.Basis3D) ## Copyright (c) 2006 Bruce Vaughan, BV Detailing & Design, Inc. ## All rights reserved. ## NOT FOR SALE. The software is provided "as is" without any warranty....
1
2550
by: =?Utf-8?B?R2F1cmF2?= | last post by:
Hi, I am using the Translate() function in one of the .XSLT file to remove the spaces, like this: <xsl:for-each select=".//Illustration"> <xsl:value-of select="translate(./@illusName, ' ', '')"/> …. This works fine with command line msxsl and XML editors like XMLSpy. However, if you use .NET's
3
12544
by: amija0311 | last post by:
Hi, I am new using DB2 9.1 database by windows base. I want to query the data that contain string then translate the string into integer using DB2. The problems is If the data is null, i got the problem to translate. How to translate string also allow null data to integer. If null data it will read as space. My Data :- GEOSEG_ID ...
4
10627
by: kovariadam | last post by:
Hi, Does anybody know why i get this error: SQL0176N The second, third or fourth argument of the TRANSLATE scalar function is incorrect. SQLSTATE=42815 with this query: SELECT TRANSLATE(p.meno, 'aaaaccdeeeiillnnoooorrsstuuuuyzzAAAACCDEEEIILLNNOOOORRSSTUUUUYZZ', 'áâãäæèïéìëíîåµñòóôöõàø¶¹»úüûùý¼¾ÁÂÃÄÆÈÏÉÌËÍÎÅ¥ÑÒÓÔÖÕÀئ©«ÚÜÛÙݬ®') FROM...
0
7693
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7604
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7916
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8117
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7660
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5498
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2101
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
932
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.