473,320 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Need help in REPLACE function in DB2

i have one scenario below,
a) ABCD DEFG EFGH ONE FGHI TWO ABCD

I want to replace ONE and TWO with nothing in DB2

The final output should be,
a) ABCD DEFG EFGH FGHI ABCD

I can use REPLACE function to replace one word. But not sure how can we handle this? Pls reply with ur thoughts
Jan 28 '08 #1
2 18768
r035198x
13,262 8TB
i have one scenario below,
a) ABCD DEFG EFGH ONE FGHI TWO ABCD

I want to replace ONE and TWO with nothing in DB2

The final output should be,
a) ABCD DEFG EFGH FGHI ABCD

I can use REPLACE function to replace one word. But not sure how can we handle this? Pls reply with ur thoughts
Please make sure you are posting in the correct forum next time.


Moved to DB2 forum.
Jan 28 '08 #2
docdiesel
297 Expert 100+
Hi,

I guess you'll have to use the Replace() function two times:

Expand|Select|Wrap|Line Numbers
  1. select
  2.   substr(
  3.     replace(
  4.       replace( my_abcd_column, 'ONE ', ''),
  5.       'TWO ', ''
  6.     ),
  7.   1, 80
  8.   ) as replaced_string
  9. from my.table;
I just added a substr() because by default Replace() returns a Varchar(4000) string.

Regards,

Bernd
Jan 28 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: J. Muenchbourg | last post by:
I'm using replace function to strip 0s from a particular string: <%=replace(rs1("racelength"),"0","''"%> but I need to also strip empty spaces from the string in question. This doesn't work :...
3
by: Claude Schneegans | last post by:
Hi, I'trying to use a regExp in Javascript to replace any all upper case word in a string by the same word having only its first letter in upper case. This expression detects the words: /()(+)/g...
5
by: adrian zaharia | last post by:
Hello, Is it possible to use Replace function in a query against an excel file? I am trying this test code and gives me an error: Set cnnExcel = Server.CreateObject("ADODB.Connection")...
3
by: Dave | last post by:
I have an Access 2K application that is distributed to about a dozen users (all with identical NT environments and identical Access versions, object libraries and service packs). I am using the VBA...
3
by: Andy Sutorius | last post by:
Hi, I read the thread (2/16/05) regarding a replace function in C# however it didn't answer my question. I have a string which is building an insert sql statement and I would like to replace...
4
by: Lauren Wilson | last post by:
Hi folks, We have a need to replace sub strings in certain message text. We use the Office Assistant to display help and often use the imbedded formatting commands. Those of you who have used...
1
by: tugsy | last post by:
Hi, How do I use the replace function to replace 2 different parts in a DB. Dim id,newsitem,newsbody,dt,createdby id = request("id") newsitem = replace(request("newsitem"), "'", "''")...
8
by: Warren Moxley | last post by:
Hi there, i've been searching for a C String search and replace function. I need to find all occurrences of " " in a char* array, and replace them with another char, I know how to do this in...
1
by: seanmatthewwalsh | last post by:
Hi I have a website that uses an Access 2003 database. I have controls on my pages that are bound to SqlDataSources that pull data from this database. In a couple of them, I need to use the...
2
by: ArunDhaJ | last post by:
Hi, I'm having a DataTable with a column named "Phones" having value like (901) 789 1234<BR>(901) 789 1235<BR>(901) 789 1221 I need to perform filtering based on the phone number of the form...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.