dbTalk Databases Forums  

Change text in a table

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss Change text in a table in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
cqmman
 
Posts: n/a

Default Change text in a table - 10-24-2007 , 09:08 AM






Hello, I want to replace a portion of a string value in columns in a
table.

Lets say I have a table called TABLE_TEST with something like this:

value....................string value
1............................string1\string3
2............................string1\string4

I want it to be like this:

value....................string value
1............................string2\string3
2............................string2\string4


Will the following work?

UPDATE TABLE_TEST
SET string_value =REPLACE(string_value,'string1','string2');

I was also looking a SELECT REPLACE, but it seems like the above would
work?
Cheers


Reply With Quote
  #2  
Old   
Mark D Powell
 
Posts: n/a

Default Re: Change text in a table - 10-24-2007 , 10:04 AM






On Oct 24, 10:08 am, cqmman <cqm... (AT) yahoo (DOT) co.uk> wrote:
Quote:
Hello, I want to replace a portion of a string value in columns in a
table.

Lets say I have a table called TABLE_TEST with something like this:

value....................string value
1............................string1\string3
2............................string1\string4

I want it to be like this:

value....................string value
1............................string2\string3
2............................string2\string4

Will the following work?

UPDATE TABLE_TEST
SET string_value =REPLACE(string_value,'string1','string2');

I was also looking a SELECT REPLACE, but it seems like the above would
work?
Cheers
Why ask when you can try the statement?

If you do not want to update the target table till you know for sure
your solution is working then either create some test data and try it
in test or create some test tables with a little sample data and try
it.

There is also the rollback command to prevent making the change
permanent, providing you are not using a tool with autocommit set on.

HTH -- Mark D Powell --



Reply With Quote
  #3  
Old   
cqmman
 
Posts: n/a

Default Re: Change text in a table - 10-24-2007 , 03:09 PM



On 24 Oct, 16:04, Mark D Powell <Mark.Pow... (AT) eds (DOT) com> wrote:
Quote:
On Oct 24, 10:08 am, cqmman <cqm... (AT) yahoo (DOT) co.uk> wrote:





Hello, I want to replace a portion of a string value in columns in a
table.

Lets say I have a table called TABLE_TEST with something like this:

value....................string value
1............................string1\string3
2............................string1\string4

I want it to be like this:

value....................string value
1............................string2\string3
2............................string2\string4

Will the following work?

UPDATE TABLE_TEST
SET string_value =REPLACE(string_value,'string1','string2');

I was also looking a SELECT REPLACE, but it seems like the above would
work?
Cheers

Why ask when you can try the statement?

If you do not want to update the target table till you know for sure
your solution is working then either create some test data and try it
in test or create some test tables with a little sample data and try
it.

There is also the rollback command to prevent making the change
permanent, providing you are not using a tool with autocommit set on.



Well yes good point. But I am not an expert in Oracle so don't want to
go around creating tables and stuff in a live DB (god knows how to
create a new Oracle DB, I don't without hitting the manuals!!).

I did actually try it using TOAD but couldn't see any useful output,
but I think that was because I the string I was looking for didn't
exist in the first place in that table..

Cheers



Reply With Quote
  #4  
Old   
Mark D Powell
 
Posts: n/a

Default Re: Change text in a table - 10-26-2007 , 06:34 PM



On Oct 24, 4:09 pm, cqmman <cqm... (AT) yahoo (DOT) co.uk> wrote:
Quote:
On 24 Oct, 16:04, Mark D Powell <Mark.Pow... (AT) eds (DOT) com> wrote:





On Oct 24, 10:08 am, cqmman <cqm... (AT) yahoo (DOT) co.uk> wrote:

Hello, I want to replace a portion of a string value in columns in a
table.

Lets say I have a table called TABLE_TEST with something like this:

value....................string value
1............................string1\string3
2............................string1\string4

I want it to be like this:

value....................string value
1............................string2\string3
2............................string2\string4

Will the following work?

UPDATE TABLE_TEST
SET string_value =REPLACE(string_value,'string1','string2');

I was also looking a SELECT REPLACE, but it seems like the above would
work?
Cheers

Why ask when you can try the statement?

If you do not want to update the target table till you know for sure
your solution is working then either create some test data and try it
in test or create some test tables with a little sample data and try
it.

There is also the rollback command to prevent making the change
permanent, providing you are not using a tool with autocommit set on.

Well yes good point. But I am not an expert in Oracle so don't want to
go around creating tables and stuff in a live DB (god knows how to
create a new Oracle DB, I don't without hitting the manuals!!).

I did actually try it using TOAD but couldn't see any useful output,
but I think that was because I the string I was looking for didn't
exist in the first place in that table..

Cheers- Hide quoted text -

- Show quoted text -
Just select from the table and browse the results. Then pick some
strings that are there and write some queries to perform the desired
changes in the select list so the only thing you change is what is
displayed.

No need to actually update the data to see the effects of the
functions.

Oracle Express is free and pretty much self-installs. It will run on
regular Windows XP or Linux.

HTH -- Mark D Powell --




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.