Replace any occurence of a character in a varchar2 column

What would be the best way to replace any occurence of a character in a column (varchar2) of a table?
Lets say we want to replace any occurence of the character ~ by the character & in the column c1 of the table t.
Is it possible in pure SQL?
I did it in PL/SQL in a while loop but I am pretty sure there is a way to do that in a single SQL statement. Am I right on wrong?
Thanks
Best regards,
Carl

The Ampersand has a special meaning in SQL to mark a variable.
That's why you need to set 'scan off' or 'define off' or
For more information see here
http://download-west.oracle.com/docs/cd/B10501_01/server.920/a90842/ch13.htm#1012408
set scan off
update t
set c1=replace(c1, '~', '&');

Similar Messages

  • Strange Problem When Inserting " £ " character in a varchar2 column

    Hello
    This is a very strange issue i am facing when i use SQL+ on different clients.
    Client 1 ( SQL+) 9.2.0.4.0
    conn scott@ora9i
    SQL> insert into dummy values( '£');
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select * from dummy;
    A
    ¿
    Client 2 ( SQL+) 9.2.0.4.0
    conn scott@ora9i
    SQL> insert into dummy values( '£');
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select * from dummy;
    A
    £
    Has any one faced this issue before , I am sure it is something to do with Client Language / Character .
    Any help would be much appreciated.
    Thanks
    Harshad

    Cheers Mate , You are a Star ,
    Thanks Once again .
    Regards
    Harshad

  • Insert ' character in a varchar2 column

    How can i insert ' character in a column. For example I want to insert
    HARINDER ' KANDA
    in a name column in one of tables. I get the message "Quoted String not properly terminated"

    Hello Dear,
    Just use single quotes two times instead of one like:
    HARINDER''KANDA
    Remember that it's two single quotes one after another not a double quote.

  • Storing a Non Printable -from keyboard- Character in Varchar2 Column

    Hi,
    I want to store a non-printable character in a varchar2 column. This character should be non-printable -from keyboard- for all character sets -or very difficult to print from keyboard-. It doesn't matter, whether it can be displayed on screen or not. It does matter INSTR function returns the character position of that character. It should be able to import export data without any problem for any NLS specific operating environment. For example, I plan to use chr(1) do you think it's appropriate? I appreciate your helps.
    Best Regards,
    Salim

    What is the business requirement you're trying to satisfy?
    If your database character set is based on ASCII, CHR(1) (the Start of Header) character is likely to be transferred between systems without character set conversion. Non-ASCII character sets (i.e. Big5 for Chinese data) don't necessarily share the same control characters, though, and generally won't have the same binary representation of an ASCII control character (so CHR(1) in a non-ASCII based database wouldn't necessarily return the same character that CHR(1) would in an ASCII based database).
    Justin

  • How to count number of occurences of a character  in a string

    I want to get the count of occurences of a character within a string. Is there any function for this or should i go for a PLSQL.
    For example is the sting is "occurences" & if i search for character "c", the answer should be 3.
    Regards,
    Sunil.

    SQL> select length('occurence') - length(replace('occurence','c')) from dual;
    LENGTH('OCCURENCE')-LENGTH(REPLACE('OCCURENCE','C'))
    3

  • Replace a single character in a textual column in sql server

    Hello,
    could you confirm to me that:
    UPDATE TableName
    SET LastName = REPLACE(LTRIM(RTRIM(LastName)), 'A', 'B')
    replaces every occurrence of character A with character B, in selected column, regardless 
    of the position of the letter A? (I.E., it could be only at the beginning of the last name, at the both i.e., at the beginning and somewhere in a middle etc....just any occurrence of it?)

    select REPLACE(LTRIM(RTRIM(lastname)), 'A', 'B') from tablename
    Yes, It will update all occurence of character 'A' of lastname.
    You can also execute the select statement for cross verfication
    -Prashanth

  • Replacing any non english Characters

    How can I Replace any non english characters I have alot of the characters that look like a block.
    --John                                                                                                                                                                                                                   

    Probably the easiest way to code would be to convert the string to a byte array and back again using the ASCII character encoding. That should give you ? for any non ASCII characters.
    Something like;
    String newString = new String(oldString.getBytes("ASCII"), "ASCII");

  • Replace all occurences in 4.6c

    Hi,
    I have a program which analyse system and gives some output.(Regarding programs,FM's etc).
    I need to run this my present server which is of 4.6c.
    But this program developed in ECC 6.0 and when i loaded this notepad program it was giving some errors.
    One error is REPLACE all occurrences of '('  in i_userexit-txt WITH space.
    In 4.6 c it is not accepting ALL OCCURENCES.
    It is accepting only Replace first occurence.
    What i need to do to replace all occurences in 4.6C?
    I there any statement to replace all Occurences?
    I searched in ABAP help  for 4.6c also.
    Please help to correct this.
    Regards,
    Krishna.

    you can do something like this, this wil do REPLACE ALL OCC...:
    WHILE sy-subrc EQ 0.
    REPLACE ... " acc. to 4.6 Syntax ...
    ENDWHILE.

  • Replace any special charecter with space

    Hi all,
    I would like to remove any occurence of special charecter that may belong to  specific language(ä)  or (* & %).
    The input may be a  string in  parameter variable or a file input.
    Regards,
    Sourya

    hi,
    constants: con_cr type x value '0D'. or try '0D0A'
    replace con_cr with space into X.
    else
    go through this"http://help.sap.com/abapdocu_70/en/ABAPREPLACE_IN_PATTERN.htm"
    cheers,
    Bhavana
    Edited by: Bhavana Amar on Apr 15, 2010 8:18 AM

  • How to replace multiple occurences of space in a string to a single space?

    How to replace multiple occurences of space in a string to a single space?

    Hi,
    try this code.
    data : string1(50) type c,
              flag(1) type c,
              dummy(50) type c,
              i type i,
              len type i.
    string1 = 'HI  READ    THIS'.
    len = strlen( string1 ).
    do len times.
    if string1+i(1) = ' '.
    flag = 'X'.
    else.
    if flag = 'X'.
    concatenate dummy string1+i(1) into dummy separated by space.
    clear flag.
    else.
    concatenate dummy string1+i(1) into dummy.
    endif.
    endif.
    i = i + 1.
    enddo.
    write : / string1.
    write : / dummy.

  • Mail Merge script to replace any blank fields with specific text

    In InDesign Mail Merge I would like to replace any blank fields with specific text. For example if we have four fields (A, B, C & D) to merge, and field A is blank, it would insert field C.
    In essence leaving no blank fields but replacing a blank field with another specific field.
    I have read that inDesign does have Mail Merge limitations but if there is a script that we could run that would solve our problem.
    Please let me know if you can help?

    I take from the lack of response it is not possible to do this in InDesign.

  • How to find and replace any string between " "

    Hi everyone,
    Here my sample
    String szTest;
    szTest = "Yellow banana";
    szTest = "Blue monkey";
    szTest = "Red mango";
    szTest is only needed when it's in testing progress. Now I want to put all of that in the /*comment*/ so the released program won't run those code any more (but still keep szTest so I can use it for future develop testing).
    So Here what I want after using the Find and Replace Box:
    //String szTest; //Manual
    /*szTest = "Yellow banana";*/ //use find and replace
    /*szTest = "Blue monkey";*/ //use find and replace
    /*szTest = "Red mango";*/ //use find and replace
    I think I can do this with Regular expressions or Wildcards. But I don't know how to find and replace any string between " and ".
    Find: szTest = " ??Any string?? ";
    Replace with: /*szTest = " ??Any string?? ";*/
    Thanks for reading.

    Hi Nathan.j.Smith,
    Based on your issue, I suggest you can try the Joel's suggestion check your issue again. In addition, I find a MSDN document about how to use the Regex.Replace Method to match a regular expression pattern with a specified replacement string,
    maybe you will get some useful message.
    https://msdn.microsoft.com/en-us/library/xwewhkd1(v=vs.110).aspx
    If the above suggestion still could not provide you, could you please tell me what language you use to create the program for finding and replace any string using regular expression so that we will find the correct programming develop forum to support this
    issue?
    Best Regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • To Extend the length/character in the text column in FBCJ

    Hi Experts,
    Is there any way to extend the length/character in the text column in FBCJ? If yes then kindly revert me back as soon as possible. My Client needs more characters then the exist one..
    Thanks in Advance

    Hi
    You have two text fields
    Addit .text1 with 100 length
    Addit text2 with 30 length
    If you still need more ask your abaper to check table ISCJ_E_POSTINGS with field text100 and text30
    Srinivas

  • Sql query: number of occurence of cellData on more thann one column in tabl

    I have employee table contains following rows.
    INSERT INTO employee VALUES (105, 'Srinath','vijay','Aeronautics', 27, 33000);
    INSERT INTO employee VALUES (105, 'Kumble','Anil','Aeronautics', 27, 33000);
    INSERT INTO employee VALUES (105, 'Prabhakar','Manoj','Aeronautics', 27, 33000);
    INSERT INTO employee VALUES (105, 'Srinath','Jawagal','Aeronautics', 27, 33000);
    INSERT INTO employee VALUES (105, 'Jawagal','Srinath','Aeronautics', 27, 33000);
    INSERT INTO employee VALUES (105, 'Mishra','Anil','Aeronautics', 27, 33000);
    INSERT INTO employee VALUES (105, 'Kumble','Prabhakar','Aeronautics', 27, 33000);select distinct first_name firstName,count(1) over (partition by first_name) firstNameCount from employee;
    and i got the follwoing result.
    (Srinath 2,Kumble 2,Prabhakar 1,Jawagal 1,Mishra 1)
    Now i want to consider second and third column both and want to number of occurence of table data on these two columns
    (Srinath 3,Kumble 2,Prabhakar 2,Jawagal 2,Mishra 1,vijay 1,Anil 2,Manoj 1)As Srinath is coming 3 times, kumble 2 times, Prabhakar 2 times,Jawagal 2 times,Mishra 1 times,vijay 1 times,Anil 2 times and Manoj 1 times.
    What will be my sql query?

    Try this
    select name, count(name) over(partition by name) cnt
      from (select first_name from employee union all select last_name from employee)

  • Inputing the character 'ł' into a varchar2 variable in an oracle database?

    how do I input the character 'ł' into a varchar2 variable in an oracle database?
    I tried in sql plus or PL/SQL developer, I think the app I need it for is run through Oracle forms. each time it appears as a question mark when I cut and psate it from MS word.

    Can anyone help?

Maybe you are looking for

  • How's the new Magic Mouse?

    Specifically the tracking? Thinking of getting one when they become available this week but would appreciate some iMac people feedback first. I'm a designer so good tracking and preciseness are pretty important. Currently have the might mouse and har

  • Stereo V. Mono Track

    By all means, someone please direct me to the thread if this has already been covered (which, being that it seems soooo basic, I wouldn't doubt that it has been). I've been selecting all my tracks as stereo. What's the difference/pros and cons? I rea

  • Can I de-install ios 8.0.2 from my iphone 5s

    can I un-install ios 8.0.2 from my iphone 5s

  • Attach  txt file

    begin Gen_Ces_Mail.email_files('[email protected]' -- van adres , '[email protected]' -- naar adres , 'test mail' -- onderwerp , 'message: test message' -- bericht , cesFiles('/usr/lib/oracle/xe/app/oracle/admin/XE/dpdump/test.txt) end; Can anybody h

  • Using premier pro on 4k display

    hi I'm thinking of buying adobe and using adobe premier pro on a 4k display but have been reading people complaining that even after scaling in windows it has no effect on premier pro and the text is tiny?