Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to replace part of string in a column, in oracle

Tags:

sql

oracle

I am using oracle, toad.

I want to replace , with backspace.

Column consists of: bla bla foo ,CALL HELPDESK

It has to replace: bla bla foo CALL HELPDESK

Basically , should be removed

I tried like this:

UPDATE Mytable t
   SET column = REPLACE(t.U_MSG, ''%, CALL HELPDESK'', '% CALL HELPDESK')
like image 690
niru dyogi Avatar asked Oct 15 '14 14:10

niru dyogi


People also ask

How can I replace part of a string in a column in SQL?

SQL Server REPLACE() FunctionThe REPLACE() function replaces all occurrences of a substring within a string, with a new substring. Note: The search is case-insensitive. Tip: Also look at the STUFF() function.

How do I replace a word in a string in Oracle?

Oracle REPLACE() Function This function is used to replace the sequence of character with another character in the given string.

How do I remove a specific character from a string in Oracle?

function deletePrefix(stringName in varchar2) return varchar2 is begin return regexp_replace(stringName, '^[a-zA-Z]+_', ''); end; regexp_replace(stringName, '^[a-zA-Z]+_', '');


1 Answers

REPLACE doesn't use wildcards, it simply replaces all instances of the first string with the second string. This should work:

UPDATE Mytable t
   SET column = REPLACE(t.U_MSG, ', CALL HELPDESK', ' CALL HELPDESK')
like image 158
Allan Avatar answered Oct 05 '22 03:10

Allan