Split string to multiple rows

I have a node like this in my outbound-message:
<serieNr>432243;54325435;543543;543522;5432543;543543555;</serieNr>
I need to map this to multiple (n) nodes in my target message:
<serieNr>432243</serieNr>
<serieNr>54325435</serieNr>
<serieNr>543543</serieNr>
<serieNr>543522</serieNr>
<serieNr>5432543</serieNr>
<serieNr>543543555</serieNr>
Can I do this with the standard functions in the mapping? If not I guess I have to create a Java method. The splitting should be okay, but how do I make a Java method return n-nodes?

Ketil,
The below code must work.
UDF - Advanced.(Cache- Queue, input parameter - number)
StringTokenizer st = new StringTokenizer(number[0], ";");
while(st.hasMoreTokens())
result.addValue(st.nextToken());
SeriNr >UDF->SplitByvalue(EachValue) -->SeriNr.
raj.

Similar Messages

  • Easy Question: How to split concatenated string into multiple rows?

    Hi folks,
    this might be an easy question.
    How can I split a concatenated string into multiple rows using SQL query?
    INPUT:
    select 'AAA,BBB,CC,DDDD' as data from dualDelimiter = ','
    Expected output:
    data
    AAA
    BBB
    CCC
    DDDDI'm looking for something kind of "an opposite for 'sys_connect_by_path'" function.
    Thanks,
    Tomas

    Here is the SUBSTR/INSTR version of the solution:
    SQL> WITH test_data AS
      2  (
      3          SELECT ',' || 'AAA,BBB,CC,DDDD' || ',' AS DATA FROM DUAL
      4  )
      5  SELECT  SUBSTR
      6          (
      7                  DATA
      8          ,       INSTR
      9                  (
    10                          DATA
    11                  ,       ','
    12                  ,       1
    13                  ,       LEVEL
    14                  ) + 1
    15          ,       INSTR
    16                  (
    17                          DATA
    18                  ,       ','
    19                  ,       1
    20                  ,       LEVEL + 1
    21                  ) -
    22                  INSTR
    23                  (
    24                          DATA
    25                  ,       ','
    26                  ,       1
    27                  ,       LEVEL
    28                  ) - 1
    29          )       AS NEW_STRING
    30  FROM    test_data
    31  CONNECT BY LEVEL <= LENGTH(REGEXP_REPLACE(DATA,'[^,]','')) - 1
    32  /
    NEW_STRING
    AAA
    BBB
    CC
    DDDD

  • Issue with splitting string into multiple lines

    Hi Experts,
    I have a long string s. I want to split this string into several lines each having 72 characters. For this I have done following programming:
         String s = "For the first time it includes a supplementary report attempting to determine if extreme weather
    events can be linked to human-induced climate change. The research team, including members
    of the UK Met Office, identified recent episodes of extreme weather then used a computer to
    estimate the likelihood of the episode happening in a world without increased CO2." ;
         s = s.replaceAll("[\r\n]+", " ");
         char[] sAr = s.toCharArray();
         AbstractList RecepitsList7 = new Bapitrtext.Bapitrtext_List();;
         int start = 0; // start with
         int i = 72 ;
    //     for (int i = 71; i < sAr.length; i++) {
    while (i < sAr.length) {
    //     {     if (sAr[i] == ' ')
                   Bapitrtext Recepits7 = new Bapitrtext();
                   Recepits7.setTextid("TEXT");
                   Recepits7.setTextline(s.substring(start, i).replaceAll("[\r\n]+", ""));
                   RecepitsList7.add(Recepits7);
                   start = i+1;
                   i += 72;
         input.setText(RecepitsList7);
    The output of program is as below:
    For the first time it includes a supplementary report attempting to dete
    mine if extreme weather events can be linked to human-induced climate
    hange. The research team, including members of the UK Met Office, iden
    ified recent episodes of extreme weather then used a computer to estim
    te the likelihood of the episode happening in a world without increased
    Here as we can see last characters are getting deleted by program. For example in first line
    determine 'r' is missing in extreme right.
    In 3rd line c is missing in extreme left (word change is needed. Program
    prints hange.
    Also in 3rd line extreme right 't' is missing
    Also in 4th line extreme right 'a' is missing
    Also the last line is not being printed. In last line "CO2." " should appear.
    There are two issues:
    1. Why last word of each sentence is not being printed?
    2. Why last sentence is not being printed?
    I am struggling since last 2 days. Please help. I made all changes like replacing 72 by 71 etc.
    By making such changes, I am able to print first line correctly. However under all cases
    last character of 2nd line onward is not getting displayed.
    Also last line is not getting displayed. I did every thing like using while instead of for loop etc.
    Kindly help.
    Regards,
    Gary
    Edited by: 945655 on Jul 10, 2012 11:39 PM

    String s = wdContext.currentContextElement().getExpense_Text();
         s = s.replaceAll("[\r\n]+", " ");
         char[] sAr = s.toCharArray();
         AbstractList RecepitsList7 = new Bapitrtext.Bapitrtext_List();;
         int start = 0; // start with
         int i = 72;
    while (i < sAr.length) {
                   Bapitrtext Recepits7 = new Bapitrtext();
                   Recepits7.setTextid("TEXT");
                   System.out.println(s.substring(start, i));
                   RecepitsList7.add(Recepits7);
                   start = i+1;
                   i += 72;
         input.setText(RecepitsList7);
    Edited by: 945655 on Jul 11, 2012 2:25 AM

  • Join string from multiple rows sorry doublepost

    Hi,
    my table looks like the following:
    id | count | val
    1 1 Message
    1 2 over
    1 3 Rows
    2 1 Second Message
    3 1 Third
    3 2 Message
    I need a Querry so the output looks like this:
    1 Message over Rows
    2 Second Message
    3 Third Message
    Can anyone help me? Hope the solution is not very complex, cause i'm new to sql.
    Thank You.
    Edited by: user9371064 on 01.06.2010 09:01

    Hi,
    That's called String Aggregation .
    http://www.oracle-base.com/articles/10g/StringAggregationTechniques.php
    is a good page on the subject, with deifferent techniques suitable for differetn versions of Oracle.

  • Splitting string into multiple string output

    Hello,
    I have this string input from serial port which looks like this:
    Voltage20Current10Temperature32
    They are all tab delimited. 
    And I need them to split into three outputs (possibly converted to numerals) -->
    Output1 --> 20 
    Output2 --> 10 
    Output3 --> 32 
    Your help will be appreciated. Thanks.
    Solved!
    Go to Solution.

    Hi Manu,
    Try the attached example.
    Regards,
    Nitz
    (Give Kudos to good Answers, Mark it as a Solution if your problem is Solved) 
    Attachments:
    Untitled 3.vi ‏6 KB

  • How to extract a clob xml string with multiple row of table tag. in 10g

    i have a xml value like:
    <table><c1>0</c1><c2>Mr</c2><c3>abc</c3><c4>Sharma</c4></table>
    <table><c1>0</c1><c2>Mrs</c2><c3>abcd</c3><c4>Sharma</c4></table>
    <table><c1>0</c1><c2>Mr</c2><c3>sabc</c3><c4>Sharma</c4></table>
    <table><c1>0</c1><c2>Mrs</c2><c3>sdabc</c3><c4>Sharma</c4></table>
    <table><c1>0</c1><c2>Mr</c2><c3>dabc</c3><c4>Sharma</c4></table>
    <table><c1>0</c1><c2>Mr</c2><c3>adbc</c3><c4>Sharma</c4></table>
    i want to insert each of <c> value in a table with respective columns according c1,c2,c3,c4
    pls suggest me what to do
    I use extract(xml, '/table) tab but it just read first one line & return error for other

    Can you plz explain to me thisIt is because you did not provide us with a valid xml structure so I used 11g's xmlparse function to create a xmltype even with the xml not being valid (no root tag).
    With a valid xml structure I could use the xmltype constructor instead and go on the same way as before:
    SQL> select *
      from xmltable (
             'table'
             passing xmltype ('
                            <root>
                            <table><c1>0</c1><c2>Mr</c2><c3>abc</c3><c4>Sharma</c4></table>
                            <table><c1>0</c1><c2>Mrs</c2><c3>abcd</c3><c4>Sharma</c4></table>
                            <table><c1>0</c1><c2>Mr</c2><c3>sabc</c3><c4>Sharma</c4></table>
                            <table><c1>0</c1><c2>Mrs</c2><c3>sdabc</c3><c4>Sharma</c4></table>
                            <table><c1>0</c1><c2>Mr</c2><c3>dabc</c3><c4>Sharma</c4></table>
                            <table><c1>0</c1><c2>Mr</c2><c3>adbc</c3><c4>Sharma</c4></table>
                            </root>').extract ('root/table')
             columns c1 number path 'c1', c2 varchar2 (4) path 'c2', c3 varchar2 (6) path 'c3', c4 varchar2 (6) path 'c4')
            C1 C2     C3        C4      
             0 Mr     abc       Sharma  
             0 Mrs    abcd      Sharma  
             0 Mr     sabc      Sharma  
             0 Mrs    sdabc     Sharma  
             0 Mr     dabc      Sharma  
             0 Mr     adbc      Sharma  
    6 rows selected.

  • Join string from multiple rows

    Hi,
    my table looks like the following:
    id | count | val
    1 1 Message
    1 2 over
    1 3 Rows
    2 1 Second Message
    3 1 Third
    3 2 Message
    I need a Querry so the output looks like this:
    1 Message over Rows
    2 Second Message
    3 Third Message
    Can anyone help me? Hope the solution is not very complex, cause i'm new to sql.
    Thank You.

    Try this:
    WITH SRC AS(
    select '1' id, '1' cnt, 'Message' val from dual union all
    select '1', '2', 'over' from dual union all
    select '1', '3', 'Rows' from dual union all
    select '2', '1', 'Second Message' from dual union all
    select '3', '1', 'Third' from dual union all
    SELECT '3', '2', 'MESSAGE' FROM DUAL
    SELECT ID, substr(replace(SYS_CONNECT_BY_PATH(VAL, '#sep#'),'#sep#', ' '),2)
    FROM SRC
    where connecT_by_isleaf = 1
    START WITH CNT = 1
    CONNECT BY PRIOR CNT + 1 = CNT AND ID = PRIOR ID
    ;On 11g a recursive common table expression also works:
    WITH SRC AS(
    select '1' id, '1' cnt, 'Message' val from dual union all
    select '1', '2', 'over' from dual union all
    select '1', '3', 'Rows' from dual union all
    select '2', '1', 'Second Message' from dual union all
    select '3', '1', 'Third' from dual union all
    SELECT '3', '2', 'MESSAGE' FROM DUAL
    RECURSIVE(id, cnt, val) AS(
      SELECT ID, CNT, VAL FROM SRC
      WHERE CNT = 1
      UNION ALL
      SELECT SRC.ID, SRC.CNT, REC.VAL || ' ' || SRC.VAL
      FROM RECURSIVE REC
      JOIN SRC ON (REC.ID = SRC.ID AND REC.CNT + 1 = SRC.CNT)
    SELECT ID, VAL
    FROM RECURSIVE R1
    WHERE NOT EXISTS( SELECT 1 FROM RECURSIVE
                      WHERE R1.ID = ID AND r1.cnt < cnt
    ORDER BY ID
    ;

  • Return 2 values (string, number) multiple rows, from java stored function

    I would like to return 2 values (String, number prefered but String, String will work) from a java stored function.
    I was able to successfully return a varray of varchar2 values but I was wondering if it is possible to return 2 values by using a varray?
    Is it even possible? I tried using combinations of types which included a varray of objects (with 2 attributes) or a type as table of objects but I couldn't figure out how in my java code to set these values. Also what would my java function return type be and what Oracle type would map to it?
    Any help and examples or pointers would be great.
    Thanks,
    Dennis

    Thanks to all. I finally figured it out through all the pieces on the web.
    Here is what worked for me. First create 2 oracle types. One object type to represent the "columns" I will pass back:
    CREATE OR REPLACE TYPE COST_OBJ AS OBJECT (COST_NAME NVARCHAR2(50), COST_VALUE number ) NOT FINAL
    note: make sure the "strings" are defined as NVARCHAR2 or Java will puke if it is just VARCHAR2.
    Then create a table type to hold your objects defined as following:
    CREATE OR REPLACE TYPE COST_OBJ_TABLE is table OF COST_OBJ
    Then create the oracle stored function that is a wrapper to the java function:
    CREATE OR REPLACE FUNCTION get_Costs(Name VARCHAR2, evalDate VARCHAR2, fuelCodeID NUMBER) return COST_OBJ_TABLE
    is language java name
    'com.costs.storedProcedures.Cost.getCosts(java.lang.String, java.lang.String, int) return oracle.sql.ARRAY'
    Once that is done, Oracle is ready. The Java function looks something like this:
    public ARRAY getCosts(String name, String evalDate, int fuelCodeID) {
    DBAccess da = getDBAccess();
    // get a handle on the connection
    Connection conn = da.getConnection();           
    // The stuff that will be returned should be as type object array
    // make it to the size of the number of fuelcomponents passed in
    Object[] returnStuff = new Object[3];
    // create the type of struct that is defined on the database
    StructDescriptor structDesc =
    StructDescriptor.createDescriptor("CY_UMAP.COST_OBJ", conn);
    for (int i = 0; i < returnStuff .size(); i++) {
    Object[] costValues = new Object[]{
         "This is object " + i,
         new Integer ( i ) };
    STRUCT cost_obj = new STRUCT(structDesc, conn, costValues);
    returnStuff[i] = cost_obj;
    ArrayDescriptor x_ad = ArrayDescriptor.createDescriptor (
    "CY_UMAP.COST_OBJ_TABLE", conn);
    ARRAY x_array = new ARRAY(x_ad, conn, returnStuff);
    return x_array;
    I hope this helps others.
    Dennis

  • Convert comma separated to string into multiple row

    Hi,
    I have SQL query which will fetch the data like below.
    {code}
    ID     NAME     CODE
    1     A,B          5,2
    2     X              10
    3     Z               4
    {code}
    So now i have to split the data like below
    {code}
    ID     NAME     CODE
    1     A               5
    1     B               2
    2     X              10
    3     Z               4
    {code}

    https://forums.oracle.com/thread/2549548

  • Is there a way in Oracle to return multiple rows as a single string?

    Hi gurus,
    I just got help from your guys fixing my dynamic sql problem. What I am doing in that function is to return a single string from multiple rows and I use it in the select statement. It works fine once the problem was solved. But is there any way in Oracle to do this in the select statement only? I have a table that stores incidents (incident_id is the PK) and another table that stores the people that are involved in an incident.
    Incident_table
    (incident_id number PK);
    Incident_people_table
    (incident_id number PK/FK,
    person_id number PK);
    Now in a report, I need to return the multiple rows of the Incident_People_table as a single string separated by a comma, for example, 'Ben, John, Mark'. I asked the SQL Server DBA about this and he told me he can do that in SQL Server by using a variable in the sql statement and SQL Server will auomatically iterate the rows and concatenate the result (I have not seen his actual work). Is there a similar way in Oracle? I have seen some examples here for some similar requests using the sys_connect_by_path, but I wonder if it is feasible in a report sql that is already rather complex. Or should I just stick to my simpler funcion?
    Thanks.
    Ben

    Hi,
    May be, this example will help you.
    SQL> CREATE TABLE Incident_Table(
      2    incident_id number
      3  );
    Table created.
    SQL> CREATE TABLE Person_Table(
      2    person_id number,
      3    person_name VARCHAR2(200)
      4  );
    Table created.
    SQL> CREATE TABLE Incident_People_Table(
      2    incident_id number,
      3    person_id number
      4  );
    Table created.
    SQL> SELECT * FROM Incident_Table;
    INCIDENT_ID
              1
              2
    SQL> SELECT * FROM Person_Table;
    PERSON_ID PERSON_NAME
             1 John
             2 Mark
             3 Ben
             4 Sam
    SQL> SELECT * FROM Incident_People_Table;
    INCIDENT_ID  PERSON_ID
              1          1
              1          2
              1          3
              2          1
              2          2
              2          4
    6 rows selected.
    SQL> SELECT IT.*,
      2    (
      3      WITH People_Order AS (
      4        SELECT IPT.incident_id, person_id, PT.person_name,
      5          ROW_NUMBER() OVER (PARTITION BY IPT.incident_id ORDER BY PT.person_name) AS Order_Num,
      6          COUNT(*) OVER (PARTITION BY IPT.incident_id) AS incident_people_cnt
      7        FROM Incident_People_Table IPT
      8          JOIN Person_Table PT USING(person_id)
      9      )
    10      SELECT SUBSTR(SYS_CONNECT_BY_PATH(PO.person_name, ', '), 3) AS incident_people_list
    11      FROM (SELECT * FROM People_Order PO WHERE PO.incident_id = IT.incident_id) PO
    12      WHERE PO.incident_people_cnt = LEVEL
    13      START WITH PO.Order_Num = 1
    14      CONNECT BY PRIOR PO.Order_Num = PO.Order_Num - 1
    15    ) AS incident_people_list
    16  FROM Incident_Table IT
    17  ;
    INCIDENT_ID INCIDENT_PEOPLE_LIST
              1 Ben, John, Mark
              2 John, Mark, SamRegards,
    Dima

  • How to display each character of an input string in different rows

    Dear Members,
    I want to write a SQL or PL/SQL where in I can separate and display each character of an input string into multiple rows.
    For eg, the input string is TESTING, I want the result to be displayed as following:
    1 T
    2 E
    3 S
    4 T
    5 I
    6 N
    7 G
    I know we can use substr, but it returns me only one or more than one characters consecutively.
    Please help me get the desired output.
    Thanks in advance.

    Hi,
    Perhaps
    with a as
    select 'TESTING' text from dual
    select level, substr(a.text,level,1)
    from a
    connect by level <= length(a.text)

  • BAPI_CATIMESHEETMGR_INSERT - BAPI_CATIMESHEETMGR_INSERT - MULTIPLE ROWS

    Hi to all,
    I'm using bapi BAPI_CATIMESHEETMGR_INSERT to insert hours in CAT2 Transaction (timesheet ) .
    The function seems to be working fine . The only thing that I don't understand is why it splits records on multiple rows.  For example I append records in CATSRECORDS_IN structure to pass hours (first record on first row ) and the second one on the second row for the same wbe in a different day column. In CAT2 (after I have executed bapi ) I'm expecting to have all hours in the same first row but I have multiple rows as records I have append in CATSRECORDS_IN.
    Plaese do you have any suggestion ?
    Many thanks in advance
    Andrew

    Marking this question as answered.  We found another alternative..did not use the SHORTETEXT field.

  • Splitting a concatenated string to multiple cells in a row in BIP Reports

    Hello Experts,
    Let me how to split a concatenated string into multiple cells in BIP reports rtf.
    Ex:
    string: acg;ghdf;tesrlkjj;hvfffda
    has to placed in multiple cells like
    string1: acg
    string2: ghdf
    string3: tesrlkjj
    string4: hvfffda
    Appreciate your quick reply.
    Please drop in the pseudo code.
    Thanks & Regards
    Syed

    The report is based on a standard sql query such as
    select item1, item2, item3, item4, item5, item6, item7
    from mytable
    order by item1Wanted to put that in as I am not using an interactive report.
    Thanks
    Wally

  • Splitting multiple rows onto one row with different fields

    Hi all,
    I have a table. One Course_Code have multiple section_codes i.e. ("NUM" column does not relate to sectype its just an order!)
    Code--------num----Sec_code---Sectype---DESC----------------WEIGHT
    1603--------1-------7427-----------C------------Coursework--------     50
    1603--------2-------7428-----------E------------     Exam----------------     50
    When I query this table i want to be able to see the coursework, exam split on the same row. i.e.
    Code-----Coursework---------Exam
    1603-----C=50------------------E=50
    any help would be great

    Hi,
    "Splitting" means taking an item (such s a string like 'C=50') and diviiding it into smal;ler items (such as the sub-strings 'C' and '50'). Are you really trying to split something, or are you trying to do just the opposite (e.g., combine smaller strings into a bigger string)?
    I think what you're looking for is a Pivot . Like so many other things, exactly how to do it depends on your version of Oracle and your requirements.
    Here's one way:
    SELECT       code
    ,       MIN (CASE WHEN descr = 'Coursework' THEN sectype END)
           ||  '='
           MIN (CASE WHEN descr = 'Coursework' THEN weight  END)     AS coursework
    ,       MIN (CASE WHEN descr = 'Exam'       THEN sectype END)
           ||  '='
           MIN (CASE WHEN descr = 'Exam'           THEN weight  END)     AS exam
    FROM       table_x
    GROUP BY  code
    ;This will work in Oracle 8.1 and higher. Starting in Oracle 11.1, you could also use the SELECT ... PIVOT feature.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables, and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using.

  • Split single row in multiple rows based on date range

    I need sql script that can split single row in multiple rows based on start date and end date column in table.
    Thank you

    I agree to your suggestion of having a dates table permanently in the database. Thats how we also do for most of our projects as well
    But in most projects the ownership  of table creation etc lies with the client as they will be the DBAs and will be design approval authorities. What I've seen is the fact that though
    many of them are in favour of having calendar table they dont generally prefer having a permanent table for numbers in the db. The best that they would agree is for creating a UDF which will have
    tally table functionality built into it based on a number range and can be used in cases where we need to multiply records as above.
    Wherever we have the freedom of doing design then I would also prefer creating it as a permanent table with required indexes as you suggested.
    >> many of them are in favour of having calendar table they dont generally prefer having a permanent table
    Those people do not understand about database and are not DBAs :-)
    It is our job to tell them what is right or wrong.
    ** This is a real story! I had a client several years back, who was the CEO of a software company.
    He use the query:
    select * from table_name
    In order to get the last ID!
    The table_name was actually a view that took data from several tables, and the main table that he wanted to get the ID included several string columns, with lot of data!
    he actually pulled all this data to the application, just to get the lat ID in a specific table!
    It is our job as Consultants or DBAs to fix's his misunderstanding :-)
      Ronen Ariely
     [Personal Site]    [Blog]    [Facebook]

Maybe you are looking for