Replace of characters with storeb prozedure

Hi,
I want to write a stored prozedure that has as source and target a varchars2 field.
What I want wo do is like the follwing:
source:a, k, ch, c
target:d, o, v, ie
Word example:
source: jed
target: and
The text of the source field has to be analysed and transformed not only letter by letter, because some combinations have two letters like the example with ch.
Thanks for help,
Walter

Hi,
Why not have a lookup table with source, target and a sequence to know the order to replace. Because of you need to replace ch and c, you need to know the first to be replace, is ch or c ? The result is not the same.
SQL> select * from replace;
SO TA        SEQ
a  d           1
k  o           2
ch v 3
c ie 4
j  a           5
e  n           6
d  d           7
7 rows selected.
SQL> create or replace function freplace(wstring varchar2)
  2  return varchar2
  3  as
  4  w_string varchar2(4000):=wstring;
  5  begin
  6  for x in (select * from replace order by seq) loop
  7      w_string := replace(w_string,x.source,x.target);
  8  end loop;
  9  return w_string;
10  end;
11  /
Function created.
SQL> select freplace('School') School, freplace('jed') jed from dual;
SCHOOL   JED
Svool         and
SQL> truncate table replace;
Table truncated.
SQL> insert into replace values ('a','d',1);
1 row created.
SQL> insert into replace values ('k','o',2);
1 row created.
SQL> insert into replace values ('c','ie',3);
1 row created.
SQL> insert into replace values ('ch','v',4);
1 row created.
SQL> select * from replace;
SO TA        SEQ
a  d           1
k  o           2
c ie 3
ch v 4
SQL> select freplace('School') from dual;
FREPLACE('SCHOOL')
SiehoolNicolas.
Message was edited by:
N. Gasparotto

Similar Messages

  • Replacing unauthorized characters with space

    Hi friends,
    There is a set of authorized characters. The authorized characters are
    abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789<space>
    If any character other than these characters should be replaced with space.
    For example, "I like foot-ball" should be changed to "I like foot ball"
    "Where are you?" should be changed to "Where are you"
    "red / blue" should be changed to "red   blue"
    I use Oracle 11.2.
    Thanks in advance!

    Using regular expression you can do this.
    SQL> with t
      2  as
      3  (
      4  select 'I like foot-ball' str
      5    from dual
      6  )
      7  select str
      8       , regexp_replace(str, '[^a-z0-9[:space:]]', ' ', 1, 0, 'i') new_str
      9    from t;
    STR              NEW_STR
    I like foot-ball I like foot ball
    You can read more about regular expression from the document.
    Using Regular Expressions in Oracle Database
    Message was edited by: Karthick_Arp
    Edited the Pattern after seeing franks post.

  • How to replace special characters with html code characters automatically?

    A colleague and I work on these html pages. They eventually end up as emails, but we have the cold fusion server to pre process them. One thing we are trying to do is eliminate problems caused by unencoded copyright, trademark and smart quote symbols.
    How could I create an array of find / replace commands in the header so it processes the HTML with correct character codes.
    I"m not cold fusion aware, so any kind of starter info would be great. Eventually I might add more replacements to the array.
    As an example TM (font character) would process to &trade; and a smart quote or apostrophe would process to a straight one. an en dash character would become &ndash;
    Because we copy paste from places, this often happens and it seems like cold fusion could solve the problem quickly and repeatedly all at once.
    thanks for any help
    -smick

    CF has a built in HTMLEditFormat function for handling <  &  > characters.  For handling trademark and smart quote characters you might try searching for a user defined function at http://cflib.org or writing a user defined function yourself that will handle the specific characters needed in your application.

  • Does trim replace some characters with control code versions in xml?

    I am using trim to remove extra white space and linefeeds from xml files and it works fine except that occasionally it replaces xml close element symbols (>) with the control code > used to delineate a > symbol that is not to be interpreted as as the xml character. What gives here? I thought all trim did was eliminate leading and trailing characters whose code was greater than '\u0020'.
    I am using Java 1.5 but this happened with 1.4 as well.

    Yes,
                             <md.decideddate>20060612</md.decideddate>
    apparently has the final '>' replaced by &gt.
    This does not happen consistently and can only be seen when loaded to IE. The Framework that I am working with in Websphere sees the error but neither XMLSpy or Eclipse has a problem with the file.
    Here's what I get when I load the file to IE:\
    An invalid character was found in text content. Error processing resource 'file:///C:/Projects/Rex/testdata/input/content/R...
    <md.dates><md.filedate>May 26, 2006</md.filedate><md.decideddate>20060526</md.decideddate&g...
    I find this very strange.

  • Replacing Special Characters With Its Actual Value

    Hi All,
    Does anyone has any idea how to replace an extended character (ASCII value ranging from 128 to 255) to its actual character set in SQL/PLSQL?
    For example: “½” needs to be replaced to “1/2”
    “¼” needs to be replaced to “1/4”
    Ultimately if the value is “California 71 ½ ” then the result should be “California 71 1/2”.
    Thanks for your time!
    Regards,

    user10088255 wrote:
    Hi All,
    Does anyone has any idea how to replace an extended character (ASCII value ranging from 128 to 255) to its actual character set in SQL/PLSQL?You can also use POSIX Character Equivalence Class to match characters having the same base character as the character you specify.
    --Extended ASCII (ISO Latin-1):
    á     #225
    â     #226
    ã     #227
    ä     #228
    å     #229
    æ       #230
    SQL> select regexp_replace('á,â,ã,ä,å,æ','[[=a=]]','a') str from dual;
    STR
    a,a,a,a,a,a

  • Identifying patterns in a string & replacing all characters with 1st digit

    Morning folks. Interesting problem on hand. I have a situation where I have a varchar2 text field where I have different paterns of a sequence of numbers somewhere in the string. I guess, I could write a function where by I accept the whole string and then identify one of the patters below and then finally replace only the recognized pattern with the first digit all the way through to the end of that pattern.
    The catch here is that there could be free text before and after the string but there will be spaces when free text ends and the patern begins.
    Here are a few patterns I would be interested in. The MAX length is 19 as in Cases 1 and 3.
    1. 9999 9999 9999 9999
    2. 9999999999999999
    3. 9999-9999-9999-9999
    4. 9999-9999-99-99999
    5. 9999-999999-99999So, here would be an example of the problem in hand :
    Call received on 9/22/2009.
    5123-4532-8871-9876
    Please follow up by 10/22/2009So, the desired output would be :
    Call received on 9/22/2009.
    5555-5555-5555-5555
    Please follow up by 10/22/2009Any ideas ? I am stumped at the fact of before and after text in the string, hence the question for you guys !
    Thanks !

    Here is another solution. However there has to be a better way! (I'm not a regular expression expert).
    SQL> WITH test_data AS
      2  (
      3          SELECT 'Call received on 9/22/2009.
      4          1232 3456 8765 3456
      5          Please follow up by 10/22/2009' AS DATA FROM DUAL UNION ALL
      6          SELECT 'Call received on 9/22/2009.
      7          1232345687653456
      8          Please follow up by 10/22/2009' AS DATA FROM DUAL UNION ALL
      9          SELECT 'Call received on 9/22/2009.
    10          1232-3456-8765-3456
    11          Please follow up by 10/22/2009' AS DATA FROM DUAL UNION ALL
    12          SELECT 'Call received on 9/22/2009.
    13          1232-3456-86-3456
    14          Please follow up by 10/22/2009' AS DATA FROM DUAL UNION ALL
    15          SELECT 'Call received on 9/22/2009.
    16          1232-345687-3456
    17          Please follow up by 10/22/2009' AS DATA FROM DUAL
    18  ), substring AS
    19  (
    20          SELECT  DATA AS SOURCE
    21          ,       REGEXP_INSTR
    22                  (
    23                          DATA
    24                  ,       '(([[:digit:]])+[[:space:]|-]){1,}'
    25                  ) AS PATSTART
    26          ,       REGEXP_SUBSTR
    27                  (
    28                          DATA
    29                  ,       '(([[:digit:]])+[[:space:]|-]){1,}'
    30                  ) AS PATTERN
    31          ,       19 AS MAXLENGTH
    32          FROM    test_data
    33  )
    34  SELECT  SUBSTR
    35          (
    36                  SOURCE
    37          ,       1
    38          ,       PATSTART-1
    39          ) ||
    40          TRANSLATE
    41          (
    42                  PATTERN
    43          ,       '0123456789'
    44          ,       LPAD
    45                  (
    46                          SUBSTR
    47                          (
    48                                  PATTERN
    49                          ,       1
    50                          ,       1
    51                          )
    52                  ,       10
    53                  ,       SUBSTR
    54                          (
    55                                  PATTERN
    56                          ,       1
    57                          ,       1
    58                          )
    59                  )
    60          ) ||
    61          SUBSTR
    62          (
    63                  SOURCE
    64          ,       PATSTART + MAXLENGTH
    65          )       AS NEW_STRING
    66  FROM substring
    67  /
    NEW_STRING
    Call received on 9/22/2009.
            1111 1111 1111 1111
            Please follow up by 10/22/2009
    Call received on 9/22/2009.
            1111111111111111
          Please follow up by 10/22/2009
    Call received on 9/22/2009.
            1111-1111-1111-1111
            Please follow up by 10/22/2009
    Call received on 9/22/2009.
            1111-1111-11-1111
           Please follow up by 10/22/2009
    Call received on 9/22/2009.
            1111-111111-1111
          Please follow up by 10/22/2009
    SQL>

  • Looking for, and replace special characters

    Hi
    I am quite new to AppleScript and can't figure this out. Any help would be appreciated.
    I have received several (a lot of) folders containing images with some strange characters in the file names. The images has to go to web, and I want to replace those characters with some that are web friendly. The characters in question is some Swedish A's and O's (Ä, ä, Ö, ö) and one that looks like the Apple Command symbol. (I was told this one is a combination of a and e).
    Then, I would like to replace all spaces between the words in the file names with an underscore.
    In addition, all image file names start with capitals and I would like to replace these as well.
    Thanks
    Neal
    G5   Mac OS X (10.4.6)  

    Here's a modified version of the standard script:
    try
    tell application "Finder" to set the source_folder to (folder of the front window) as alias
    on error -- no open folder windows
    set the source_folder to path to desktop folder as alias
    end try
    display dialog "Search and replace in:" buttons {"File Names", "Folder Names", "Both"} default button 3
    set the search_parameter to the button returned of the result
    repeat
    display dialog "Enter text to find in the item names:" default answer "" buttons {"Cancel", "OK"} default button 2
    set the search_string to the text returned of the result
    if the search_string is not "" then exit repeat
    end repeat
    repeat
    display dialog "Enter replacement text:" default answer "" buttons {"Cancel", "OK"} default button 2
    set the replacement_string to the text returned of the result
    if the replacement_string contains ":" then
    beep
    display dialog "A file or folder name cannot contain a colon (:)." buttons {"Cancel", "OK"} default button 2
    else if the replacement_string contains "/" then
    beep
    display dialog "A file or folder name cannot contain a forward slash (/)." buttons {"Cancel", "OK"} default button 2
    else
    exit repeat
    end if
    end repeat
    display dialog "Replace “" & the search_string & "” with “" & the replacement_string & "” in every item name?" buttons {"Cancel", "OK"} default button 2
    tell application "Finder"
    set the item_list to every item of entire contents of source_folder
    tell me
    set item_list to reverse of the item_list
    end tell
    set source_folder to source_folder as string
    repeat with i from 1 to number of items in the item_list
    set the_name to name of item i of the item_list
    set this_item to item i of the item_list
    set this_info to properties of this_item
    set the current_name to the_name
    set change_flag to false
    repeat with this_char from 1 to (count items of search_string)
    if the current_name contains item this_char of (search_string) then
    if the search_parameter is "Folder Names" and ¬
    folder of this_info is true then
    set the change_flag to true
    else if the search_parameter is "File Names" and ¬
    folder of this_info is false then
    set the change_flag to true
    else if the search_parameter is "Both" then
    set the change_flag to true
    end if
    if the change_flag is true then
    set this_item to item i of the item_list
    -- replace target string using delimiters
    set AppleScript's text item delimiters to the item this_char of search_string
    set the textitemlist to every text item of the current_name
    set AppleScript's text item delimiters to the item this_char of replacement_string
    set the newitemname to the textitemlist as string
    set AppleScript's text item delimiters to ""
    set the current_name to newitemname
    end if
    end if
    end repeat
    my setitem_name(thisitem, current_name)
    end repeat
    end tell
    beep 2
    on setitem_name(thisitem, newitemname)
    tell application "Finder"
    --activate
    set the parentcontainerpath to (get the container of this_item) as text
    if not (exists item (the parentcontainerpath & newitemname)) then
    try
    set the name of this_item to newitemname
    return this_item
    on error the error_message number the error_number
    if the error_number is -59 then
    set the error_message to "This name contains improper characters, such as a colon (:)."
    else --the suggested name is too long
    set the error_message to error_message -- "The name is more than 31 characters long."
    end if
    --beep
    tell me to display dialog the error_message default answer newitemname buttons {"Cancel", "Skip", "OK"} default button 3
    copy the result as list to {newitemname, button_pressed}
    if the button_pressed is "Skip" then return 0
    my setitem_name(thisitem, newitemname)
    end try
    else --the name already exists
    --beep
    tell me to display dialog "This name is already taken, please rename." default answer newitemname buttons {"Cancel", "Skip", "OK"} default button 3
    copy the result as list to {newitemname, button_pressed}
    if the button_pressed is "Skip" then return 0
    my setitem_name(thisitem, newitemname)
    end if
    end tell
    end setitemname
    This script variant works by accepting a source string in the form "AB" and desired string "CD". When run, ABCA will become CDCC with the sample strings.
    (19254)

  • Replace encoded characters in URL

    Hi gurus,
    I have the following requirement and I don't know how to solve it in the best way.
    I have a Z transaction for uploading a local file. This file contains URL's and after upload, there are stored in SAP.
    I need to check this URL and replace encoded characters with corresponding codes, for example: space -> %20
    How can I do this? I've been looking for a solution, but I haven't found anything usefull yet.
    Any ideas?
    Thanks a lot!

    Have a look at class CL_HTTP_UTILITY. There are some methods which looks promising.
    The method ESCAPE_URL is waht you needed.
    pass UNESCAPED = 'http://forums.sdn.sap.com/edit!default.jspa?messageID=11060123'
    output = HTTP%3a%2f%2fFORUMS%2eSDN%2eSAP%2eCOM%2fEDIT%21DEFAULT%2eJSPA%3fMESSAGEID%3d11060123
    & for vice versa use UNESCAPE_URL
    Edited by: Keshav.T on Feb 7, 2012 2:23 PM

  • Replacing windows new line characters with JAVA

    I am importing a file into the database... the file is written by a client using windows, and it is a text file.
    When there is a windows new line character at the end of the line (^M), it is getting saved to the database as part of the string value.
    When we parse this data to run a report, the (^M) are being written back out to the file and causing the fields and data not to line up.
    We want to REPLACE the ^M with some other character (whatever it doesn't matter)... how can java do that???
    We tried replacing '/n' with '###' and it will show the ###, but the line still breaks.
    TIA,
    Tonya

    The characters in question are cr = \r = ascii(13) and lf = \n = ascii(10). Windows uses CrLf, Unix uses Lf and some systems use just Cr. You can use the String.replaceAll or the pattern matching classes to fix this up, see java.util.regex.Pattern, and java.util.regex.Matcher.

  • How to replace special characters in string.

    Hello,
    I want to replace special characters such as , or ; with any other character or " ".I find out there is no such function is java for this.There is only replace() but it accepts only chars.If anybody know how to do this?.
    Thanks,

    Hello,
    I want to replace special characters such as , or ;
    with any other character or " ".I find out there is no
    such function is java for this.There is only replace()
    but it accepts only chars.If anybody know how to do
    this?.
    Thanks,Can't you just do the following?
    public class Test
         public static void main(String[] args)
         String testString = "Hi, there?";
         System.out.println(testString.replace(',',' '));
    }

  • Find and Replace Japanese characters in pdf file on iPhone

    Hi eveybody !
    I want to find and replace Japanese characters in pdf on iPhone.
    I using zlib to deflate stream - endstream block and extract text.It's work fine with latin-text.
    But when i work with japanese characters , I don't know how to do it ?
    I decode a sample japanese pdf file, and I know that each Japanese characters are performances as hex string : "<01b7><0e230a23>..."
    But i don't know how to convert Japanese characters to the hex string like that.
    Can evrybody help me?
    Thanks!

    Searching is the same process as extracting - since it's about turning page content into something understandable.  So that still remains what you need to learn/understand - of course, referring back to all the previous sections about font formats, etc.
    Replacing in PDF is EXTREMELY DIFFICULT for two reasons - subset fonts and explicit glyph positioning.  Have you determine (conceptually, if nothing else) how you plan to addresses these two issues?
    PDF doesn't do UTF8 for page content - so don't worry about that.

  • Replacing 'special' characters

    Hi all,
    I was wondering if thers is a function module, class (method) or whatever (codepage translation) to convert 'special' characters like:
    è, é, ë, ï, etc with respectively e, e, e, i?
    More generally speaking we need to convert all characters (whether it be Unicode, Latin-1, etc.) to plain text containing only the letters of the alphabet from a-z and A-Z.
    Kind regards,
    Micky.

    @ Rainer,
    both thanks a lot for your relevant replies which are quite helpful. And I do think that we still needs some sort of intermediate table to hold at least some characters to be translated/converted into plain text.
    @ Gautham,
    I'm currently testing this function module with several codepages (parameter INTER_CP) beside the default codepage 1146. For characters like ë and ï this is definitely the way to go, but when using some characters that are really out there like ¥ŖßÞu0152u03A9u03C6, we still seem to be needing an intermediate table to replace these characters.
    But again, some very helpful answers.
    P.S. Although both answers are potentially worth 10 pts, It only seems fair to give you both the credit you deserve.

  • Replacing carriage return with HTML " br/ "

    All,
    I have a textarea in an HTML page that receives text input from the user. The text is stored in a varchar2 column and then rendered back into the HTML page as static text.
    I'd like to make it easy for the end user and not force them to enter "<br/>" characters (exactly how this forum works) for new lines and paragraphs.
    On the insert trigger for the note text, I'm thinking of using:
    :new.note_text := replace(:old.note_text, chr(0), '<br/>');1) Will this work?
    2) Is this the best way to do this?
    Thanks.

    Yes, I did mean chr(10). So I set up my trigger to include the replace() function on "note_text":
    create or replace trigger "NOTE_INSERT_TGR"
    BEFORE
    insert on "NOTE"
    for each row
    declare
      next_val number(20);
    begin
      select note_id_seq.nextval
        into next_val
        from dual;
      :new.note_id       := next_val;
      :new.note_text     := replace(:old.note_text, chr(10), '<br/>');
      :new.date_created  := sysdate;
      :new.last_modified := sysdate;
    end;
    /but nothing is being inserted into the "note_text" field. In my PL/SQL code block, I'm using the following logic for the insert statement:
      if (:P2_NOTE_TEXT is not null) then
        insert into note(application_id, note_text)
          values(:P2_APPLICATION_ID, :P2_NOTE_TEXT);
      end if;and have even tried placing the replace() function here with no results at all (probably related to some internal processing with HTMLDB).
    When I query my note table, I can verify (null) is being inserted.
    select note_id, note_text
    from note
    returns
    NOTE_ID     NOTE_TEXT
    56     (null)Any ideas why I'm losing the note text?
    Thanks.

  • Replacing a char with string in a string buffer.

    Hi all,
    I have a huge xml file. Need to search for the following characters: ^ & | \ and replace each character with \T\ \F\ \B\ \C\ respectively.
    i.e. ^ must be replaced with \T\
    & must be replaced with \F\
    I see that it can be done in case of String using replaceAll() but have no clue about achieving using the stringbuffer??
    Any help is higly appeciated.
    Thanks in advance.

    Hi all,
    I have a huge xml file. Need to search for the
    following characters: ^ & | \ and replace each
    character with \T\ \F\ \B\ \C\ respectively.
    i.e. ^ must be replaced with \T\
    & must be replaced with \F\
    I see that it can be done in case of String using
    replaceAll() but have no clue about achieving using
    the stringbuffer??
    Any help is higly appeciated.
    Thanks in advance.here the solution for your problem:
    example code as follows,
         StringBuffer stringBuffer = new StringBuffer("your xml content");           
                String xmlString = stringBuffer.toString();
                char[]  xmlCharArray =  new char[];
                xmlString.getChars(0, xmlString.length()-1, xmlCharArray, 0);
               StringBuffer alteredXmlBuf = new StringBuffer();
                for(int i=0; i<xmlCharArray.length; i++){
                               if( xmlCharArray[i] == '^'){
                                      alteredXmlBuf.append(" \\T\\") ;
                               }else if(xmlCharArray[i] == '&'){
                                      alteredXmlBuf.append(" \\F\\") ;
                               }else if(xmlCharArray[i] == '|'){
                                      alteredXmlBuf.append(" \\B\\") ;
                               }else if(xmlCharArray[i] == '\'){
                                      alteredXmlBuf.append(" \\C\\") ;
                               }else {
                                       alteredXmlBuf.append(xmlCharArray);
    now alteredXmlBuf StringBuffer object contains your solution.

  • Replace control characters in IDoc

    Hello!
    In an IDoc -> XI -> IDoc scenario we have messages failing with
    com.sap.engine.lib.xml.parser.ParserException: Invalid char #0x0(:main:, row:1, col:5446)
    Once I opened the XML using a HEX editor and had a look at the row 5446 it shows several 0x0 values as mentioned in the error message in SXMB_MONI.
    Characters with a hexcode less than 0x20 are non-printable control characters which are not allowed to appear in the text of an XML tag according to the XML specification.
    However, I'm wondering why the IDoc adapter does not delete or replace those control characters with corresponding XML entities before it reaches the Integration Engine.
    The control records are entered by business users in SAP once they fill out free text fields. Any ideas, what could be done on SAP or XI side to automatically prevent those parsing errors and have the message processing successfully? Thanks.
    Regards, Tanja

    Hello!
    Are u using "Apply Control Record Values from Payload" in the idoc receiver communciation channel
    Yes, we have the "Apply Control Record Values from Payload" indicator turned on in the receiver IDoc adapter as we need to have the IDoc control record fields filled from the IDoc XML payload.
    Regards, Tanja

Maybe you are looking for

  • After quitting Safari I receive a crash report referencing cloudd

    After a browsing session with Safari and upon quitting I receive an error dialog that references the cloudd process. Does anyone know what this is how to fix it? I also see in the console logs many references to problems with apple.com.webkit as well

  • Clearing of User Inbox

    Dear All, I have a scenario like this:while one HR user trying to trigger some automatic generated mails(from SAP to Lotus notes) related to bill settlements,he is getting message something like this in small pop-up window of SAP office express info

  • Safari, Wikipedia and strange characters

    Hi guys I'm have a problem at work with Safari. Some webpages with odd characters and are totally unreadable. For an example go to http://homepage.mac.com/thomjcook/PhotoAlbum35.html This always happens on Wikipedia but also I get it on other website

  • Forgotten the password for my previous MMC

    I had a Nokia 6110 - have now upgraded to a 6120 but upon inserting my old MMC, my phone asked for a security code. I suspect someone else used my phone and set a code for the card. How do I unlock the MMC in my new phone?

  • Service Data migration

    Hi, I need help to understand, how to migrate open service contract from legacy to SAP CRM , what all points we need to consider like planning finanical data for ERP CO integration etc... as i am new to service module..would be great if someone can s