473,406 Members | 2,259 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,406 software developers and data experts.

SQL REPLACE STATEMENT - CONSOLIDATION

Can these lines of sql statements be consolidated into one sql statement
(possibly using reg exps??)

BEGIN CODE
++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++
Update applications Set news_article = replace(news_article, '<FONT
face="Times New Roman" color=#000000 size=3>', '');
Update applications Set news_article = replace(news_article, '<P
class=MsoNormal style="MARGIN: 0cm 0cm 0pt">', '');
Update applications Set news_article = replace(news_article,
'<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office"
/>', '');
Update applications Set news_article = replace(news_article, '<o:p>', '');
Update applications Set news_article = replace(news_article, '</o:p>', '');
Update applications Set news_article = replace(news_article, '</P>', '');
Update applications Set news_intro = replace(news_intro, '<FONT face="Times
New Roman" color=#000000 size=3>', '');
Update applications Set news_intro = replace(news_intro, '<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt">', '');
Update applications Set news_intro = replace(news_intro, '<?xml:namespace
prefix = o ns = "urn:schemas-microsoft-com:office:office" />', '');
Update applications Set news_intro = replace(news_intro, '<o:p>', '');
Update applications Set news_intro = replace(news_intro, '</o:p>', '');
Update applications Set news_intro = replace(news_intro, '</P>', '');
Update applications Set news_article = replace(news_article, '<SPAN lang=FR
style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial; mso-ansi-language:
FR">', '');
Update applications Set news_article = replace(news_article, '<SPAN lang=FR
style="COLOR: black; mso-ansi-language: FR">', '');
Update applications Set news_article = replace(news_article, '</SPAN>', '');
Update applications Set news_article = replace(news_article, '<FONT
color=#000000>', '');
Update applications Set news_article = replace(news_article, '</FONT>', '');
Update applications Set news_article = replace(news_article, '<SPAN lang=FR
style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial; mso-ansi-language:
FR">', '');
Update applications Set news_article = replace(news_article, '<SPAN lang=FR
style="COLOR: black; mso-ansi-language: FR">', '');
Update applications Set news_article = replace(news_article, '</SPAN>', '');
Update applications Set news_article = replace(news_article, '<FONT
color=#000000>', '');
Update applications Set news_article = replace(news_article, '</FONT>', '');
Update applications Set news_intro = replace(news_intro, '<SPAN lang=FR
style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial; mso-ansi-language:
FR">', '');
Update applications Set news_intro = replace(news_intro, '<SPAN lang=FR
style="COLOR: black; mso-ansi-language: FR">', '');
Update applications Set news_intro = replace(news_intro, '</SPAN>', '');
Update applications Set news_intro = replace(news_intro, '<FONT
color=#000000>', '');
Update applications Set news_intro = replace(news_intro, '</FONT>', '');

++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++
END CODE

Many Thanks
Jul 17 '05 #1
4 3003
Craig Keightley wrote:
Can these lines of sql statements be consolidated into one sql statement
(possibly using reg exps??)

BEGIN CODE
++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++
Update applications Set news_article = replace(news_article, '<FONT
face="Times New Roman" color=#000000 size=3>', '');
Update applications Set news_article = replace(news_article, '<P
.... etc. etc.


What are you trying to do? These statments are to clean HTML tags from
records in your database. If it's a one-off to clean up your database
then just run it as is. If it's a regular job then you ought to look
into cleaning the data before it gets there.

strip_tags is very useful for cleanup purposes. You can specify which
tags to explicitly allow (<b>,<i> etc) and write the clean version to
your database.

Jul 17 '05 #2
>Can these lines of sql statements be consolidated into one sql statement
(possibly using reg exps??)
You might be able to put this in one big mess:

Update applications Set news_article = replace(replace(replace(replace(replace(replace(re place(replace(replace(news_article, '<SPAM>', ''), '</SPAM>', '') ...

but it looks very messy to maintain. You can also do news_article
and news_intro in the same statement.

Gordon L. Burditt
BEGIN CODE
+++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++
Update applications Set news_article = replace(news_article, '<FONT
face="Times New Roman" color=#000000 size=3>', '');
Update applications Set news_article = replace(news_article, '<P
class=MsoNormal style="MARGIN: 0cm 0cm 0pt">', '');
Update applications Set news_article = replace(news_article,
'<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office"
/>', '');
Update applications Set news_article = replace(news_article, '<o:p>', '');

....
Jul 17 '05 #3
Hopefully its a one off
I have a page where the user can isert a record but it uses a div id
instead of a textarea When the form is submitted, it passes the data in the
div id to a hidden field and the hidden field is entered into the db.
The reason for this is the user can format the text to make it bold text and
or italic. But thats all they can do. If a user copies and pastes text
froma word document, it also copies the format of the text from that
document. Therefore all the additional xmal items are included.
I would use strip_tags but the allowable tags are used in the document also
(<P> tag etc)

Thanks for the help though

Craig
"Kevin Thorpe" <ke***@pricetrak.com> wrote in message
news:41***********************@news.easynet.co.uk. ..
Craig Keightley wrote:
Can these lines of sql statements be consolidated into one sql statement
(possibly using reg exps??)

BEGIN CODE
++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++
Update applications Set news_article = replace(news_article, '<FONT
face="Times New Roman" color=#000000 size=3>', '');
Update applications Set news_article = replace(news_article, '<P ....
etc. etc.


What are you trying to do? These statments are to clean HTML tags from
records in your database. If it's a one-off to clean up your database then
just run it as is. If it's a regular job then you ought to look into
cleaning the data before it gets there.

strip_tags is very useful for cleanup purposes. You can specify which tags
to explicitly allow (<b>,<i> etc) and write the clean version to your
database.

Jul 17 '05 #4
*** Craig Keightley escribió/wrote (Wed, 6 Oct 2004 12:15:47 +0100):
Can these lines of sql statements be consolidated into one sql statement
(possibly using reg exps??)


You're going to kill your database server, which is the typical bottleneck
in a dynamic web site. My suggestion:

1) Write a PHP function to cleanup text
2) Get data from DB
3) Clean data with your PHP function
4) Put data back into DB
--
-+ Álvaro G. Vicario - Burgos, Spain
+- http://www.demogracia.com (la web de humor barnizada para la intemperie)
++ Las dudas informáticas recibidas por correo irán directas a la papelera
-+ I'm not a free help desk, please don't e-mail me your questions
--
Jul 17 '05 #5

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

Similar topics

8
by: middletree | last post by:
What's wrong with this code? strLongDesc = Replace(Replace(Replace(Replace(Trim(Request.Form("LongDesc")),"'","''"),vbC rLf,"<br>"),"<",&lt;),"<",&gt;) Background: This field is a textarea, and I...
1
by: eddie wang | last post by:
I try to replace the following STATEMENT ONE with STATEMENT TWO. But it doesn't work. How to make it work??? Thanks. STATEMENT ONE: <td colspan="10" align="center"><a...
9
by: Richard Gutery | last post by:
I have this piece of code in an ASP page: replace (strRootDir, "\", "/", -1) When I run the script I get: Microsoft VBScript compilation (0x800A0414) Cannot use parentheses when calling a Sub ...
2
by: Little PussyCat | last post by:
Hello, I need to be able to replace only the first occurance of a space character in a column. Reason being is the data in the column I am trying to replace seems to have umpteen space...
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...
8
by: Guy | last post by:
Hi, I'm trying to run this code : strFileContentsHTML.Replace(vbLf, "<br>") strFileContentsHTML.Replace(vbCrLf, "<br>") strFileContentsHTML.Replace(vbCr, "<br>") It doesn't replace newline...
2
by: Curtiosity | last post by:
I have done a create or replace view called creditcard1. If I do a "select * from creditcard1" it retrieves the data just fine. If I try to do a statement where I am listing the column names it...
10
by: bobtehdog | last post by:
Column Consolidation. My problem is this. I have to sort each of the def1-def23 columns from the old table into the def1-def6 columns from the new table preserving the other data in the records....
2
by: Jeremy | last post by:
I am trying to replace a string "P" with "\P" as long as the string "P" does not already have a "\" in front. for my search string I've used @"(P)" so my regex replace statement is: ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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...

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.