Comparing string delimited by semicolon in a column with another string

Hi
I have requirement like comparing a column which contains the string delimited by semi colon with a string delimited by semicolon. i.e. comparing the multiple values with multiple values.for this purpose i am using the following code
select ams.application_id,it_mgmt_chain
FROM tb_ams038_application ams,THE
(SELECT CAST
(Appmgmt_Str_To_Table
(NVL (ams.it_mgmt_chain,
) AS appmgmt_tabletype_string
FROM DUAL
AND (COLUMN_VALUE IN ( SELECT COLUMN_VALUE
FROM THE
(SELECT CAST
(Appmgmt_Str_To_Table
(nvl(NVL (replace('1234;8383;83939;93939',',',';'),
ams.it_mgmt_chain
) AS appmgmt_tabletype_string
FROM DUAL
here in the above it_mgmt_chain has the string containing numbers seperated by semi colon. and the Appmgmt_Str_To_Table function used to split the string and return it in the form of list. and appmgmt_tabletype_string is a varray which is created for spliting and storing purpose.
Can anyone please suggest the best way to do this task as the above code is giving a performance issue.

This example uses a "|" not a semicolon but it leverages the REGEXP_SUBSTR, SUBSTR, LENGTH to perform a parsing action.
http://blog.mclaughlinsoftware.com/plsql-programming/a-result-cache-function-returning-a-collection/
You may wish to remove the "THE" and replace it with "TABLE" too. Good luck.

Similar Messages

  • How to replace a particular striing with another string in jtextpane

    how to get replace a particular string with another string of a jtextpane without taking the text in a variable using getText() method .

    Thanks for your answer,
    "relevant object" means for you datasources, transfer rules and transformations ?
    With the grouping option "Save for system copy" I can't take easily all datasources, and others objects
    Will I have to pick all object one by one ?
    What would be the adjustement in table RSLOGSYSMAP ? For the moment it's empty.
    Regards
    Guillaume P.

  • Replacing a special character in a string with another string

    Hi
    I need to replace a special character in a string with another string.
    Say there is a string -  "abc's def's are alphabets"
    and i need to replace all the ' (apostrophe) with &apos& ..which should look like as below
    "abc&apos&s def&apos&s are alphabets" .
    Kindly let me know how this requirement can be met.
    Regards
    Sukumari

    REPLACE
    Syntax Forms
    Pattern-based replacement
    1. REPLACE [{FIRST OCCURRENCE}|{ALL OCCURRENCES} OF]
    pattern
              IN [section_of] dobj WITH new
              [IN {BYTE|CHARACTER} MODE]
              [{RESPECTING|IGNORING} CASE]
              [REPLACEMENT COUNT rcnt]
              { {[REPLACEMENT OFFSET roff]
                 [REPLACEMENT LENGTH rlen]}
              | [RESULTS result_tab|result_wa] }.
    Position-based replacement
    2. REPLACE SECTION [OFFSET off] [LENGTH len] OF dobj WITH new
                      [IN {BYTE|CHARACTER} MODE].
    Effect
    This statement replaces characters or bytes of the variable dobj by characters or bytes of the data object new. Here, position-based and pattern-based replacement are possible.
    When the replacement is executed, an interim result without a length limit is implicitly generated and the interim result is transferred to the data object dobj. If the length of the interim result is longer than the length of dobj, the data is cut off on the right in the case of data objects of fixed length. If the length of the interim result is shorter than the length of dobj, data objects of fixed length are filled to the right with blanks or hexadecimal zeroes. Data objects of variable length are adjusted. If data is cut off to the right when the interim result is assigned, sy-subrc is set to 2.
    In the case of character string processing, the closing spaces are taken into account for data objects dobj of fixed length; they are not taken into account in the case of new.
    System fields
    sy-subrc Meaning
    0 The specified section or subsequence was replaced by the content of new and the result is available in full in dobj.
    2 The specified section or subsequence was replaced in dobj by the contents of new and the result of the replacement was cut off to the right.
    4 The subsequence in sub_string was not found in dobj in the pattern-based search.
    8 The data objects sub_string and new contain double-byte characters that cannot be interpreted.
    Note
    These forms of the statement REPLACE replace the following obsolete form:
    REPLACE sub_string WITH
    Syntax
    REPLACE sub_string WITH new INTO dobj
            [IN {BYTE|CHARACTER} MODE]
            [LENGTH len].
    Extras:
    1. ... IN {BYTE|CHARACTER} MODE
    2. ... LENGTH len
    Effect
    This statement searches through a byte string or character string dobj for the subsequence specified in sub_string and replaces the first byte or character string in dobj that matches sub_string with the contents of the data object new.
    The memory areas of sub_string and new must not overlap, otherwise the result is undefined. If sub_string is an empty string, the point before the first character or byte of the search area is found and the content of new is inserted before the first character.
    During character string processing, the closing blank is considered for data objects dobj, sub_string and new of type c, d, n or t.
    System Fields
    sy-subrc Meaning
    0 The subsequence in sub_string was replaced in the target field dobj with the content of new.
    4 The subsequence in sub_string could not be replaced in the target field dobj with the contents of new.
    Note
    This variant of the statement REPLACE will be replaced, beginning with Release 6.10, with a new variant.
    Addition 1
    ... IN {BYTE|CHARACTER} MODE
    Effect
    The optional addition IN {BYTE|CHARACTER} MODE determines whether byte or character string processing will be executed. If the addition is not specified, character string processing is executed. Depending on the processing type, the data objects sub_string, new, and dobj must be byte or character type.
    Addition 2
    ... LENGTH len
    Effect
    If the addition LENGTH is not specified, all the data objects involved are evaluated in their entire length. If the addition LENGTH is specified, only the first len bytes or characters of sub_string are used for the search. For len, a data object of the type i is expected.
    If the length of the interim result is longer than the length of dobj, data objects of fixed length will be cut off to the right. If the length of the interim result is shorter than the length of dobj, data objects of fixed length are filled to the right with blanks or with hexadecimal 0. Data objects of variable length are adapted.
    Example
    After the replacements, text1 contains the complete content "I should know that you know", while text2 has the cut-off content "I should know that".
    DATA:   text1      TYPE string       VALUE 'I know you know',
            text2(18)  TYPE c LENGTH 18  VALUE 'I know you know',
            sub_string TYPE string       VALUE 'know',
            new        TYPE string       VALUE 'should know that'.
    REPLACE sub_string WITH new INTO text1.
    REPLACE sub_string WITH new INTO text2.

  • Search given string array and replace with another string array using Regex

    Hi All,
    I want to search the given string array and replace with another string array using regex in java
    for example,
    String news = "If you wish to search for any of these characters, they must be preceded by the character to be interpreted"
    String fromValue[] = {"you", "search", "for", "any"}
    String toValue[] = {"me", "dont search", "never", "trip"}
    so the string "you" needs to be converted to "me" i.e you --> me. Similarly
    you --> me
    search --> don't search
    for --> never
    any --> trip
    I want a SINGLE Regular Expression with search and replaces and returns a SINGLE String after replacing all.
    I don't like to iterate one by one and applying regex for each from and to value. Instead i want to iterate the array and form a SINGLE Regulare expression and use to replace the contents of the Entire String.
    One Single regular expression which matches the pattern and solve the issue.
    the output should be as:
    If me wish to don't search never trip etc...,
    Please help me to resolve this.
    Thanks In Advance,
    Kathir

    As stated, no, it can't be done. But that doesn't mean you have to make a separate pass over the input for each word you want to replace. You can employ a regex that matches any word, then use the lower-level Matcher methods to replace the word or not depending on what was matched. Here's an example: import java.util.*;
    import java.util.regex.*;
    public class Test
      static final List<String> oldWords =
          Arrays.asList("you", "search", "for", "any");
      static final List<String> newWords =
          Arrays.asList("me", "dont search", "never", "trip");
      public static void main(String[] args) throws Exception
        String str = "If you wish to search for any of these characters, "
            + "they must be preceded by the character to be interpreted";
        System.out.println(doReplace(str));
      public static String doReplace(String str)
        Pattern p = Pattern.compile("\\b\\w+\\b");
        Matcher m = p.matcher(str);
        StringBuffer sb = new StringBuffer();
        while (m.find())
          int pos = oldWords.indexOf(m.group());
          if (pos > -1)
            m.appendReplacement(sb, "");
            sb.append(newWords.get(pos));
        m.appendTail(sb);
        return sb.toString();
    } This is just a demonstration of the technique; a real-world solution would require a more complicated regex, and I would probably use a Map instead of the two Lists (or arrays).

  • How can I substitute a string with another string in a file

    I have a file. I have a substitute a keyword with another string in all the occurences of a file. How can I do this?

    I'm gonna give you the benifit of the doubt and assume you didn't mean to double post your question.
    As to substitute a keyword with a string one way is to read in the file and run it through a StreamTokenizer class to break it into words. Pull one word at a time, check it, and stick it into a StringBuffer. Once your done with the file overwrite it with what is in the StringBuffer.
    Another way might be to use the RandomAccessFile class, but I'm not really familiar with that because I hardly ever use it.

  • Replace a string with another string in a file

    I have to replace a string with another string. Say for example in a html file it got a line like,
    <a href="##"></a>
    now i want to replace this ## with the full derived path like
    "c;\\sample folder\\sample subfolder\\samplefile.html"
    can someone help me to do this?
    pls tell me from the file opening till closing the file.

    I have to replace a string with another string. Say
    for example in a html file it got a line like,
    <a href="##"></a>
    now i want to replace this ## with the full derived
    path like
    "c;\\sample folder\\samplesubfolder\\samplefile.html"
    can someone help me to do this?
    pls tell me from the file opening till closing the
    file.
    public class Buckel {
      final static String CONST = "c:\\sample folder\\samplesubfolder\\samplefile.html";
      public Buckel() {
      public static void main ( String[] argv )  throws Exception {
        int    idx = 0;
        String in  = "<a href=\"##\"></a>",   // We'll imagine this just gets here somehow. If it's on the i/p file then take the '\' out B4 and aft the '##'.
               out = "";
        idx = in.indexOf( "##" );
        if ( idx > 0 ) {
          out = in.substring( 0, idx ) + CONST + in.substring( idx+=2, in.length() );
        System.out.println( out );
    }

  • Creating new String using only specific set of chars from another String

    I've performance troubles doing this task:
    I have a very long String A (up to 1 million character length)
    This String contains different characters.
    I need to create a String B containing only specific characthers (with a defined character code)
    An example:
    String A: [80]='P' [65]='A' [71]='G' [69]='E'For example I want to extract only character 65 and 71
    String B: [65]='A' [71]='G'I already did the code to do this, (it's quite simple) but I think I have some very big performance issues, and I suppose I can do this task much more quickly!!
    String out = "";
              for (counter = 0; counter < text.length(); counter++) {
                   char currentchar = text.charAt(counter);
                   int currentvalue = (new Integer(currentchar)).intValue();
                   switch (currentvalue) {
                   case 65:
                        char[] newstring = new char[1];
                        newstring[0] = currentchar;
                        out += new String(newstring);
                        break;
                   case 71: //
                        break;
                   // other cases
                   default:
                        // nothing to do...
              }Can you suggest me something to improve the performances?
    Thank you!

    If you've got a number of characters in your acceptance set I'd use indexOf, and I'd probably use StringCharacterIterator. Mind you, with a million characters I'd probably not load them all at once anyway, but process them as streams.
    StringBuffer out = new StringBuffer(s.length() / 5); // allocate plenty
    StringCharacterIterator it = new StringCharacterIterator(s);
    for(char c = it.first(); c != CharacterIterator.DONE; c = it.next())
      if("AG".indexOf(c) >= 0)
          out.append(c);
    return c.toString();

  • Replaces all occurnces of one String with another String in a given source

    Hi all I had found that there is a lot of interest int this topic. there is a little piece of code that I wrote for myself recently, so I fgigured that it might be helpful for some...
    This method will scan through a string "source", find all of the occurances of a String "before" and replace them with the "after".
    Enjoy :-)
    public static String replace(String source, String before, String after)
    StringBuffer sb = new StringBuffer(source);
    int startpos = source.indexOf(before);
    int endpos = startpos + before.length();
    int i = startpos;
    while( i > -1 )
         if( startpos > -1 && endpos <= source.length() )
         source = sb.replace(startpos, endpos, after).toString();
         int lastReplace = source.lastIndexOf(after) + after.length();
         if(lastReplace <= source.length())
              startpos = source.substring(lastReplace, source.length() ).indexOf(before);
                   endpos = startpos + before.length();
                   i = startpos;
         else
              i = source.length();
         else
              i = -1;
    return source;
    Oh yeah if you want, you can visit my site http://www.infobrokery.com it is where this code is used to replace the text URL with html.

    Since 1.4 the String class has a replaceAll method ...

  • Parse column with csv string into table with one row per item

    I have a table (which has less than 100 rows) - ifs_tables that has two columns: localtable and Fields. Localtable is a table name and Fields contains a subset of columns from that table. Fields is a comma delimited list:  'Fname,Lname'. It looks like
    this:
    localtable         fields
    =========  =============
    customertable   fname,lname
    accounttable     type,accountnumber
    Want to end up with a new table that has one row per column. It should look like this:
    TableName             ColumnName
    ============ ==========
    CustomerTable        Fname
    CustomerTable        Lname
    AccountTable          Type
    AccountTable          AccountNumber
    Tried this code but have two issues (1) My query using the Splitfields functions gets "Subquery returned more than 1 value" (2) some of my Fields has hundreds of collumns in the commas delimited list. It will returns "Msg 530, Level 16, State
    1, Line 8. The statement terminated. The maximum recursion 100 has been exhausted before statement completion.maxrecursion greater than 100." Tried adding OPTION (maxrecursion 0) in the Split function on the SELECT statment that calls the CTE, but
    the syntax is not correct.
    Can someone help me to get this sorted out? Thanks
    DROP FUNCTION [dbo].[SplitFields]
    go
    CREATE FUNCTION [dbo].[SplitFields]
    @String NVARCHAR(4000),
    @Delimiter NCHAR(1)
    RETURNS TABLE
    AS
    RETURN
    WITH Split(stpos,endpos)
    AS(
    SELECT 0 AS stpos, CHARINDEX(@Delimiter,@String) AS endpos
    UNION ALL
    SELECT endpos+1, CHARINDEX(@Delimiter,@String,endpos+1)
    FROM Split
    WHERE endpos > 0
    SELECT 'Id' = ROW_NUMBER() OVER (ORDER BY (SELECT 1)),
    'Data' = SUBSTRING(@String,stpos,COALESCE(NULLIF(endpos,0),LEN(@String)+1)-stpos)
    FROM Split --OPTION ( maxrecursion 0);
    GO
    IF OBJECT_ID('tempdb..#ifs_tables') IS NOT NULL DROP TABLE #ifs_tables
    SELECT *
    INTO #ifs_tables
    FROM (
    SELECT 'CustomerTable' , 'Lname,Fname' UNION ALL
    SELECT 'AccountTable' , 'Type,AccountNumber'
    ) d (dLocalTable,dFields)
    IF OBJECT_ID('tempdb..#tempFieldsCheck') IS NOT NULL DROP TABLE #tempFieldsCheck
    SELECT * INTO #tempFieldsCheck
    FROM
    ( --SELECT dLocaltable, dFields from #ifs_tables
    SELECT dLocaltable, (SELECT [Data] FROM dbo.SplitFields(dFields, ',') ) from #ifs_tables
    ) t (tLocalTable, tfields) -- as Data FROM #ifs_tables
    SELECT * FROM #tempFieldsCheck

    Try this
    DECLARE @DemoTable table
    localtable char(100),
    fields varchar(200)
    INSERT INTO @DemoTable values('customertable','fname,lname')
    INSERT INTO @DemoTable values('accounttable','type,accountnumber')
    select * from @DemoTable
    SELECT A.localtable ,
    Split.a.value('.', 'VARCHAR(100)') AS Dept
    FROM (SELECT localtable,
    CAST ('<M>' + REPLACE(fields, ',', '</M><M>') + '</M>' AS XML) AS String
    FROM @DemoTable) AS A CROSS APPLY String.nodes ('/M') AS Split(a);
    Refer:-https://sqlpowershell.wordpress.com/2015/01/09/sql-split-delimited-columns-using-xml-or-udf-function/
    CREATE FUNCTION ParseValues
    (@String varchar(8000), @Delimiter varchar(10) )
    RETURNS @RESULTS TABLE (ID int identity(1,1), Val varchar(8000))
    AS
    BEGIN
    DECLARE @Value varchar(100)
    WHILE @String is not null
    BEGIN
    SELECT @Value=CASE WHEN PATINDEX('%'+@Delimiter+'%',@String) >0 THEN LEFT(@String,PATINDEX('%'+@Delimiter+'%',@String)-1) ELSE @String END, @String=CASE WHEN PATINDEX('%'+@Delimiter+'%',@String) >0 THEN SUBSTRING(@String,PATINDEX('%'+@Delimiter+'%',@String)+LEN(@Delimiter),LEN(@String)) ELSE NULL END
    INSERT INTO @RESULTS (Val)
    SELECT @Value
    END
    RETURN
    END
    SELECT localtable ,f.Val
    FROM @DemoTable t
    CROSS APPLY dbo.ParseValues(t.fields,',')f
    --Prashanth

  • How to replace part of a String with another String :s ?

    Got a String
    " Team_1/Team_2/Team_3/ "
    And I want to be able to rename part of the string (they are seperated by '/'), for example I want to rename "Team_3" to "Team C", and "Team_1" to "Team A" while retaining the '/' character how would I do this?
    I have tried using String.replace(oldValue, newValue); but this doesnt work, any ideas?

    What do you mean that it doesn't work? You do know that the method returns the modified string? The actual string that you invoke the method on is not altered.
    /Kaj

  • How to union mulitple itemset column with another  tables

    Hi ,
    i have the following table called itemset as below ,
    A
    ;1;10;2;3;4;5;7;8
    ;10;2;3;4;5;8;9
    ;10;2;3;4;8;9
    and another table called temp as below ,
    B
    1
    2
    6
    and need to find the union of those 2 tables as below ,
    A---------------------| B--| A Union B
    ;1;10;2;3;4;5;7;8 | 1 |;1;10;2;3;4;5;7;8
    ;1;10;2;3;4;5;7;8 | 2 |;1;10;2;3;4;5;7;8
    ;1;10;2;3;4;5;7;8 | 6 |;1;10;2;3;4;5;7;8;6
    ;10;2;3;4;5;8;9 |1 |;10;2;3;4;5;8;9;1
    ;10;2;3;4;5;8;9 |2 |;10;2;3;4;5;8;9
    ;10;2;3;4;5;8;9 |6 |;10;2;3;4;5;8;9;6
    ;10;2;3;4;8;9 |1 |;10;2;3;4;8;9;1
    ;10;2;3;4;8;9 |2 |;10;2;3;4;8;9
    ;10;2;3;4;8;9 |6 |;10;2;3;4;8;9;6
    any help please ,
    Edited by: user11309581 on Jun 26, 2011 10:43 PM
    Edited by: user11309581 on Jun 26, 2011 10:47 PM

    with a as (
               select ';1;10;2;3;4;5;7;8' str from dual union all
               select ';10;2;3;4;5;8;9' from dual union all
               select ';10;2;3;4;8;9' from dual
         b as (
               select '1' str from dual union all
               select '2' from dual union all
               select '6' from dual
    -- end of on-the-fly data sample
    select  a.str,
            b.str,
            case
              when a.str || ';' like '%;' || b.str || ';%' then a.str
              else a.str || ';' || b.str
            end combined_str
      from  a,
            b
    STR               S COMBINED_STR
    ;1;10;2;3;4;5;7;8 1 ;1;10;2;3;4;5;7;8
    ;1;10;2;3;4;5;7;8 2 ;1;10;2;3;4;5;7;8
    ;1;10;2;3;4;5;7;8 6 ;1;10;2;3;4;5;7;8;6
    ;10;2;3;4;5;8;9   1 ;10;2;3;4;5;8;9;1
    ;10;2;3;4;5;8;9   2 ;10;2;3;4;5;8;9
    ;10;2;3;4;5;8;9   6 ;10;2;3;4;5;8;9;6
    ;10;2;3;4;8;9     1 ;10;2;3;4;8;9;1
    ;10;2;3;4;8;9     2 ;10;2;3;4;8;9
    ;10;2;3;4;8;9     6 ;10;2;3;4;8;9;6
    9 rows selected.
    SQL>  SY.

  • LEFT JOINING with a string?

    I'm viewing code where the person left joined a column with a string.
       lu_ods.lookup_type(+) = 'FORX_ORDERPRO_ACTION'Is this just bad coding. Is there any reason why someone would do this?
    Doesn't
       lu_ods.lookup_type = 'FORX_ORDERPRO_ACTION'work just as well?

    As Sentinel said, it can change the result if you are left joining between two tables:
    with a as (
    select 1 num, 'a' col from dual UNION ALL
    select 2 num, 'b' col from dual UNION ALL
    select 3 num, 'c' col from dual
    b as (
    select 1 num, 'a' col from dual UNION ALL
    select 4 num, 'e' col from dual UNION ALL
    select 5 num, 'f' col from dual
    select *
    from a, b
    where a.num(+) = b.num
      and a.num(+) = 1;
    NUM                    COL NUM                    COL
    1                      a   1                      a  
                               5                      f  
                               4                      e  
    3 rows selectedWithout the left join on the number, we lose results:
    with a as (
    select 1 num, 'a' col from dual UNION ALL
    select 2 num, 'b' col from dual UNION ALL
    select 3 num, 'c' col from dual
    b as (
    select 1 num, 'a' col from dual UNION ALL
    select 4 num, 'e' col from dual UNION ALL
    select 5 num, 'f' col from dual
    select *
    from a, b
    where a.num(+) = b.num
      and a.num = 1;
    NUM                    COL NUM                    COL
    1                      a   1                      a  
    1 rows selected

  • Naming an object with a string.

    Is it possible to make on object that is named with a String?
    so you make a string String a = "Hello";
    and then you make an object that is called Hello.
    Does anyone know?
    thx, SJG

    AFAIK, no. But depending on what you want to do, there are various ways of storing a String on the basis of another string received at runtime.
    A HashMap, for example, could use the String "Hello" as a key to get at another string:
    HashMap map = new HashMap();
    String inputA = "hello";
    String inputB = "to be stored";
    map.put(inputA, inputB);
    System.out.println(map.get(inputA));Perhaps that might be useful to you?

  • Check if a string contains another string

    can anybody help?
    String st="DC";
    how can i check if another string contains "DC" or not?

    How bout
    if(someString.indexOf(st) != -1) {
         //someString contains st at some point
    }

  • IF statement (Compare column with String)

    Hi all,
    i want to compare the Content of a Column with a text but i always get an error message because of a Syntax error.
    It the Content of the column Approval Status is Approved the System should write in the calculated column the String "Approved"
    my code:
    =IF([ApprovalStatus]="Approved","Approved"," ")
    can you help me ? what is wrong here?
    thank you in advance

    Hi
    yes, because  you should numeric values
    Approval Status
    Value
    Approved
    0
    Rejected
    1
    Pending
    2
    Draft
    3
    Schedule
    4
    https://farhanfaiz.wordpress.com/2010/12/17/sharepoint-approval-status-value-of-publishing-pages/
    Romeo Donca, Orange Romania (MCSE, MCITP, CCNA) Please Mark As Answer if my post solves your problem or Vote As Helpful if the post has been helpful for you.

Maybe you are looking for