comma-separated string

I have a string that comes an external instrument. When it is read, he appears in a format like this:

"10,55.

11.25

13.43

15.68 "

The number of entries varies. I need to get this string in a comma-separated string that is later concatenated with another string and written to a csv file.

So how do the entry above into this: ' 10,55, 11.25, 13.43 15.68?

Thank you

There are a lot of ways. I use find and replace. See attachemt for an example.

Tags: NI Software

Similar Questions

  • Adding zero in comma separated string

    Hi all

    Currently I am working on Oracle 11 g

    I have the string as 1,12,123,1234 and my requirement is to fill the zero on every comma separated string

    My output result should be like this 0001,0012,0123,1234, what exactly does lpad('12',4,'0').

    Kindly help a query above.

    A simple trick I learned for a long time back here

    SQL> with t
      2  as
      3  (
      4  select '1,12,123,1234' str from dual
      5  )
      6  select regexp_replace(regexp_replace(str, '([[:digit:]]+)', '0000\1'), '0+([[:digit:]]{4})', '\1') str
      7    from t;
    
    STR
    -------------------
    0001,0012,0123,1234
    
    SQL>
    
  • How to remove duplicates from comma separated string


    Hi all

    I have an obligation to remove duplicates of string separated by commas:

    Some examples of code (real data can be in millions)

    {code}

    create table test_dup_del (num number (10), dup_val varchar2 (100));

    insert into test_dup_del values (1234, '1, 2, 3, 4, 3, 1');
    insert into test_dup_del values (4567,'1, 2, 2, 4, 4, 1');
    insert into test_dup_del values (7894,'1, 2, 1, 3, 3, 1');
    insert into test_dup_del values (1478, '1, 2, 4, 4, 3, 2');
    insert into test_dup_del values (2589, '1, 2, 1, 2, 1, 2');
    commit;

    (code}

    my output would be:

    1234, 1, 2, 3, 4'

    4567, '1, 2, 4'

    7894, '1, 2, 3'

    1478, 1, 2, 3, 4'

    2589, 1, 2'

    Thank you

    Rachid

    If there is a real need to split the data so that it could be corrected (before split to store correctly... Tip tip!) ...

    SQL > ed
    A written file afiedt.buf

    1 with test_dup_del (num, dup_val) as)
    2 Select 1234, 1, 2, 3, 4, 3, 1' Union double all the
    3 select 4567, 1, 2, 2, 4, 4, 1' Union double all the
    4 Select 7894, 1, 2, 1, 3, 3, 1' Union double all the
    5 Select 1478, 1, 2, 4, 4, 3, 2' of all the double union
    6 select 2589, 1, 2, 1, 2, 1, 2' of the double
    7      )
    8  --
    9. end of test data
    10-
    11, split as)
    12. Select num
    13, trim (regexp_substr(dup_val,'[^,]+',1,level)) as val
    14 from test_dup_del
    15 connect by num = num prior
    16 and level<=>
    17 and prior sys_guid() is not null
    18                )
    19, dist in (select distinct)
    20                      num
    21                      ,val
    22 split
    23              )
    24 select num
    25, listagg (val, ',') within the Group (order by val) as vals
    dist 26
    27 * group by num
    SQL > /.
    NUM OF VALS
    ---------- ------------------------------
    1234 1,2,3,4
    1478 1,2,3,4
    2589 1.2
    4567 1,2,4
    7894 1,2,3

    5 selected lines.

  • How to train a xml using a comma separated string in Xquery

    Hi all

    In my application, I need to write an Xquery query that should be an xml document. Admission to the XQuery function is an xml with an element that has the strings separated by commas. For

    example of

    < root >
    < StringComma > Hi, Hello, welcome < / StringComma >
    < / root >

    I need form an xml in such a way that it should have as many tags as the strings in < StringComma > element of the foregoing. For example, is what I want

    < Root1 >
    < String1 > Hello < / String1 >
    < String2 > Hello < / String2 >
    Welcome < String3 > < / String3 >
    < / Root1 >

    something like that. How could we do it using XQuery. Kindly help me in this.


    Thank you.

    Hello

    You can do it like this:

    declare variable $input := document{ Hi,Hello,Welcome };
    
    
    {
      for $i at $pos in fn:tokenize($input/Root/StringComma, ",")
      return element {fn:concat("String", $pos)} {$i}
    }
    
    
  • Remove duplicates of comma separated String

    Hello
    I have a column that contains the values of duplicates with separated by commas.

    Customer ID
    -----------------------------
    5,5,5,5,6,6,5,5,5,6,7,4,1,2,1,4,7,2

    I wrote this:

    Select REGEXP_REPLACE ('5, 5, 5, 5, 6, 6, 5, 5, 5, 6, 7, 4, 1, 2, 1, 4, 7, 2', ' (^ |,)([^,]*) (, \2)+','\1\2') of double;)
    ---------------------------------
    5,6,5,6,7,4,1,2,1,4,7,2

    But it eliminates only the continuous elements.
    I want to put it as:
    ---------------------
    5,6,7,4,1,2

    Help, please.
    Thank you.
    Amit

    Published by: 987565 on February 12, 2013 04:02

    Since you don't have 11 GR 2, making it a lot easier, I would use INSTR/SUBSTR to break the values, and then use START WITH / CONNECT BY to group the separate values of back together. I avoid the REGEXP stuff when I can because he uses a lot of CPU.

    WITH INDATA AS (
      select '9,9,8,8,7,7,6,6,5,5,4,4,3,3,2,2,1,1' x from dual
      union all
      select '9,9,8,8,7,7,4,4,3,3,2,2,1,1' x from dual
    ), TOKENIZED AS (
      SELECT DISTINCT A.INNUM,
      dense_rank() over(partition by innum order by b.column_value) x_rank,
      B.COLUMN_VALUE x
      FROM (select rownum innum, x from indata) a,
      table(cast(multiset(
        SELECT trim(SUBSTR(
          x,
          (case level
            when 1 then 1
            else instr(x, ',', 1, level-1) + 1
          end),
          (case instr(x, ',', 1, level)
            when 0 then 4000
            else instr(x, ',', 1, level) - 1 -
              (case level
                when 1 then 0
                else instr(x, ',', 1, level-1)
              end)
          end)
        ))
        FROM dual
        CONNECT BY level <= LENGTH(x) - LENGTH(REPLACE(x, ',', '')) + 1
      ) AS SYS.ODCIVARCHAR2LIST)) B
    )
    SELECT ltrim(sys_connect_by_path(x, ','),',') x
    FROM TOKENIZED A
    where connect_by_isleaf = 1
    START WITH X_RANK = 1
    connect by (innum, x_rank) = ((prior innum, prior x_rank + 1));
    
    X
    --------------------
    1,2,3,4,5,6,7,8,9
    1,2,3,4,7,8,9
    

    Published by: stew Ashton on February 13, 2013 15:47

  • Count the values in a comma separated string

    Hi, I have the following requirement.
    The entry is as below:
      with test as 
      (select 'ABC,DEF,GHI,JKL,MNO' mystring from dual   union all
        select 'ABC,DEF'  from dual union all
        select 'JKL,MNO' from dual )   
        select * from test
    And production is expected to be of the island below
    str            cnt
    'ABC'        2
    'DEF'        2
    'GHI'        1
    'JKL'         2
    'MNO'       2
    I tried this query to get, as above, but the wrong exit
      with test as 
      (select 'ABC,DEF,GHI,JKL,MNO' mystring from dual   union all
        select 'ABC,DEF'  from dual union all
        select 'JKL,MNO' from dual )   
        select str,count(*) from (
        select regexp_substr(mystring,'[^,]+',1,level) str
            from test
         connect by level <= length(regexp_replace(mystring,'[^,]+')) + 1 )
         group by str
    Please help me to get the output as required

    Thank you
    SQL> with test
      2  as
      3  (
      4  select 'ABC,DEF,GHI,JKL,MNO' mystring from dual   union all
      5  select 'ABC,DEF'  from dual union all
      6  select 'JKL,MNO' from dual
      7  )
      8  select str, count(*)
      9    from (
     10              select regexp_substr(mystring, '[^,]+', 1, level) str
     11                from test
     12             connect by level <= length(mystring) - length(replace(mystring, ',')) + 1
     13                 and mystring = prior mystring
     14                 and prior sys_guid() is not null
     15         )
     16   group
     17      by str
     18   order
     19      by str
     20  /
    
    STR                   COUNT(*)
    ------------------- ----------
    ABC                          2
    DEF                          2
    GHI                          1
    JKL                          2
    MNO                          2
    
  • Values separated by a nested as comma from string table

    I would insert the contents of a table nested in the form of comma-separated values in a string.


    For example, I created:

    CREATE TYPE u_results AS TABLE OF VARCHAR2 (10);
    /

    CREATE TABLE example_table)
    number of obj_id,
    obj_results u_results)
    NESTED TABLE obj_results STORE AS obj_results_t;

    INSERT INTO example_table (obj_id, obj_results) VALUES (1, u_results ('OK', 'NOK', 'NN'));
    INSERT INTO example_table (obj_id, obj_results) VALUES (2, u_results ('OK', 'NOK'));

    CREATE TABLE example_table2)
    number of obj_id,
    obj_results2 VARCHAR2 (100));

    So, in the example_table2 table I would have obj_results values in obj_results2 as string separated by commas.

    for example
    OBJ_ID obj_results2
    1 OK, NOK, NN
    2 OK, NOK

    Any ideas? Thank you
    G.
    SQL>  create type u_results as table of varchar2 (10);
    /
    Type created.
    
    SQL>  select rtrim (xmlagg (xmlelement (e, column_value || ',')).extract ('//text()'), ',') csv
          from table (u_results ('AA', 'BB')) t
    /
    CSV
    ----------
    AA,BB
    1 row selected.
    
    SQL>  drop type u_results
    /
    Type dropped.
    
  • Why the function of integrated separator string is missing in Oracle?

    Hi all

    It's maybe a generic/discussion question. And it's purely for learning about how Oracle prioritizes its development on the functions in construction.

    Well, we have very userful built-in functions (http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions001.htm) is transformed during the versions of Oracle from simple to very complex (syntactic xml and data mining functions)

    But why is this important function to split a string has been neglected (may not be the right word) by Oracle.

    Be a learner curious and admirer of such a wonderful technology database called Oracle, I always thought that it must have a dedicated channel, divide the function.

    My question is: is this something that can be generalized in a built-in function?

    or

    Is he coming releases?

    At least a simple function first (I guessed right his name would be splitstr and the very basic features to do our job of splitting, maybe I'm wrong in thinking this way, please correct me if...) Thank you in advance!)

    splitstr('A,B,c',',','col')-> (separator ',' and the fractionating column mode)

    Output: A B C (three separate columns)

    splitstr('A,B,c',',','row')-> (separator ',' and the mode line split)

    Output:

    A

    B

    C

    ----------

    If oracle has this, there will be a lot of code reduced and we can be saved by connect or recursive with clause or as a matter of fact even xmltable (with or without tokenizer ) for the separation of the channels.

    What you have to say about this? You can ignore this naïve question if is not a value you answer.

    And thanks for everyone who reads this discussion!

    See you soon,.

    Manik.

    Can you please help me understand why Oracle has its participation in develping and DBMS_UTILITY.COMMA_TO_TABLE now then?

    http://docs.Oracle.com/CD/B19306_01/AppDev.102/b14258/d_util.htm

    Oracle can only tell you why they have developed this particular function. But the fact that Oracle included in a package of "utility" tells me that they do not consider that there was a generic number of use cases. These functions often begin as internal functions that Oracle decides to publish.

    But if you read this API spec you'll see that he does that to a VERY PARTICULAR use case and has several restrictions.

    The list must be a list separated by commas of non-vide: another thing that a comma-separated list is rejected. Do not count the commas inside double quotes.

    Entries in the list separated by commas may not include multibyte and dashes (-) character.

    Also, returns a collection which would normally be used only for a very limited number of items.

    It is not yet near a general-purpose function.

    A major complication with such a function in SQL is sql is generally used with more than one, or even millions, of lines.

    How you specify to Oracle where to put the collection on each of these lines?

    New - Oracle is a relational database. With the help of sql to manipulate collections is NOT a relational paradigm.

    Just my opinion. Others can and will disagree. But you may have to wait for the weekend for these answers.

  • Comma Separated Values

    Hello
    We stock values separated by commas into a table.


    IIL_CUSTOMER_TICKETS_TYPE_IDS
    -------------------------------------------------------
    1,2,3,4,5,6
    5,7,10,56,48
    12,45,56,

    I want to query this table through values separated by commas...

    Query as this select * from t1 where IIL_CUSTOMER_TICKETS_TYPE_IDS in (1,2,3)

    Help, please...

    Try this

    with mytable as
    (
    Select 'a' pass, ' 1,2,3,4,5,6"txt of all double union
    Select 'b', '5,7,10,56,48' of any double union
    Select 'c', "12,45,56" of the double
    )
    Select
    MyTable.col,
    txt
    Of
    MyTable,
    (
    Select
    level n
    Of
    (
    Select
    Max (length (txt) - length (replace (txt, ','))) as max_commas
    Of
    MyTable
    )
    connect by level<= 1="" +="">
    ) ctr
    where
    CTR.n<= 1="" +="" length="" (txt)="" -="" length="" (replace="" (txt,="">
    and regexp_substr (mytable.txt, "[^,] +', 1, n") in (1,5,7)
    order by
    MyTable.col,
    CTR.n

    http://nimishgarg.blogspot.com/2010/06/Oracle-comma-seprated-string-to-rows_16.html

    Alexander gelin
    http://nimishgarg.blogspot.com

  • comma separator

    Hello

    In Oracle 10 g, I need to split comma separation like that.

    data:

    '1,3,2,3,4,6'

    to divide like this

    Col1 col2

    1        3

    2        3

    4        6

    Thanks in advance

    Hello 00125

    This might be a solution:

    WITH TMP_TAB

    AS (SELECT '1,3,2,3,4,6' AS DOUBLE TXT)

    SELECT REGEXP_SUBSTR (txt, ' [^,] +', 1, 2 + 1 *(level-1)) AS Col1

    REGEXP_SUBSTR(txt, '[^,]+', 1, 2*level) AS Col2

    OF TMP_TAB

    CONNECTION OF level <= round((length(txt)="" -="" length(replace(txt,="" ',')))="" 2) ="" --="">10g characteristic

    ;

    Less than 11g, you can write it's simpler:

    CONNECTION OF <= regexp_count(txt="" ||="" ',',="" ',')="" 2 ="" --="">11g characteristic level

    I hope it helps.

    Best regards, David

  • The research of a column with comma separated values with ora-text

    I use the Oracle 11 g 2 XE and Oracle Text to a web search engine.

    I've now created and text indexed a CLOB keywords column that contains words separated by spaces. This allowed me to expand the search, as Oracle Text returns the rows that have one or more keywords that are stored in this column. The contents of the column are visible to the user and serves to 'expand' the search. This does not work as expected.

    But now I need support several words or even sentences. With the current configuration, Oracle Text will only search for each keyword. How should I store the phrases and configure Oracle text so that it will search entire sentences (exact match is better, but the partial match is fine too)?

    Example of content column of two lines (values separated semicolon):
    "Hello, Hello; y at - it anyone out there? Nope; »
    "the just; basic facts; »
    I found a similar question: looking for a column with values separated by commas, except that I need a solution for Oracle 11 g with it's freetext search.

    Possible solutions:
    1st solution: I thought to redraw the DB as follows. I would like to make a new array of keywords (pkID NUMBER, nonUniqueID NUMBER, singlePhrase VARCHAR2 (100 BYTE)). And I want to change the column previous keyword to KeywordNonUniqueID, holding the ID (instead of a list of values). At the time of the research I had INNER JOIN with the new keyword table. The problem with this solution is that I will get several lines containing the same data except for the sentence. I guess this will destroy the ranking?

    2nd solution: is it possible to store sentences as an XML in the column key of origin and somehow say Oracle text to search for in the XML?

    3rd solution: separate individual phrases with spaces, but replace the spaces in sentences with the underscore or something (making a single word). If a phrase "why Hello there, Johnny!" is saved as "Why_hello_there, _Johnny!

    4th solution?:

    Note that, generally, there is a lot of sentences (less than 100), nor that they will be long (one sentence will be up to 5 words).

    Also note that I am currently using CONTAINS, and needs some of its operators, to my full-text searches.

    When you talk about "phrase", do you mean "a list of words separated by a comma other sentences?

    Isn't that the definition of "sentence" used by Oracle Text, where it simply means "a list of words in the order defined."

    If I understand your requirement, you want to have data such as:

    "aa bb cc dd".
    "aa ee dd ff.

    and give priority to the first on the second if someone looking for "dd".

    First, to conduct research in the comma separated list, you should look for in a section. You can either explicitly define sections of field such as
    AA bb cc dd
    Or you can use the PHRASE special section and set the sentence delimiters correctly. This is done with the attribute BASIC_LEXER punctuation

    Then you have the number you want to find only words where they are the only words in the section. That's the same problem, I address in the last post of this forum entry:
    Contains: match exactly

    Our solution will be substantially the same, some surrounding text with special markers, and then prioritize a phrase search with these special markers each side of the word.
    We need to do a treatment some additional, although, as we need to surround each "sentence" (in your terminology) with special markers. I did it by surrounding the text with "XX1"... Condition2"then by replacing every comma with"Condition2, XX1"as part of a MULTI_COLUMN_DATASTORE:

    drop table names;
    create table names (id number primary key, text varchar2(50));
    
    insert into names values( 1, 'just and kind, kind and loving' );
    insert into names values( 2, 'just, kind' );
    
    exec ctx_ddl.drop_preference  ( 'mylex' )
    exec ctx_ddl.create_preference( 'mylex', 'BASIC_LEXER' )
    exec ctx_ddl.set_attribute    ( 'mylex', 'PUNCTUATIONS', ',' )
    
    exec ctx_ddl.drop_preference  ( 'mcds' )
    exec ctx_ddl.create_preference( 'mcds',  'MULTI_COLUMN_DATASTORE' )
    exec ctx_ddl.set_attribute    ( 'mcds', 'COLUMNS', '''XX1 ''||replace(text, '','',''XX2, XX1'')||'' XX2''' )
    
    exec ctx_ddl.drop_preference  ( 'mywl' )
    exec ctx_ddl.create_preference( 'mywl', 'BASIC_WORDLIST' )
    exec ctx_ddl.set_attribute    ( 'mywl', 'SUBSTRING_INDEX', 'YES' )
    
    create index namesindex on names(text)
    indextype is ctxsys.context
    parameters( 'datastore mcds wordlist mywl' )
    /
    
    select score(1),id,text from names where contains( text, '
    
      
        
           XX1 kind XX2 
           kind
        
      
    
    ', 1) > 0
    order by score(1) desc
    /
    

    Output of this is:

      SCORE(1)        ID TEXT
    ---------- ---------- --------------------------------------------------
         52         2 just, kind
          2         1 just and kind, kind and loving
    
  • SQL - Multiple Fetch in a single column with a comma separator

    Hello Experts,
    Good day to all...

    I need your help on the following scenarios. The following query returns all channels titleID. Rather than print them one under the other as a result of the query, I want the output to be in the batch of 25 values.i.e than each line must have 25 values separated by commas. IE if there are 100 titles satisfying the output, then there should be only four lines with and each line with 25 titles in comma separated way.
    SELECT DISTINCT title_id
               FROM pack_relation
              WHERE package_id IN (      SELECT DISTINCT fa.package_id
                                                    FROM annotation fa
                                                GROUP BY fa.package_id
                                                  HAVING COUNT
                                                            (fa.package_id) <100);
    I tried with the PL/SQL block; Whereas it is printing all the values permanently :(
    I have to stop with 25 values and display.

    If its possible with SQL block alone. then it would be a great help

                                                           
                                                                          
    DECLARE
       v_str   VARCHAR2 (32767)  := NULL;
    
       CURSOR c1
       IS
         SELECT DISTINCT title_id
               FROM pack_relation
              WHERE package_id IN (      SELECT DISTINCT fa.package_id
                                                    FROM annotation fa
                                                GROUP BY fa.package_id
                                                  HAVING COUNT
                                                            (fa.package_id) <100);
    BEGIN
       FOR i IN c1
       LOOP
          v_str := v_str || ',' || i.title_id;
       END LOOP;
       v_str := SUBSTR (v_str, 2);
       DBMS_OUTPUT.put_line (v_str);
    EXCEPTION
       WHEN OTHERS
       THEN
          DBMS_OUTPUT.put_line ('Error-->' || SQLERRM);
    END;
    Thank you...

    You can use CEIL

    Code example

    SELECT
        nt,
        LTRIM(MAX(SYS_CONNECT_BY_PATH(val,',')) KEEP (DENSE_RANK LAST ORDER BY curr),',') AS concat_val
    FROM
        (
            SELECT
                val,
                nt,
                ROW_NUMBER() OVER (PARTITION BY nt ORDER BY val)    AS curr,
                ROW_NUMBER() OVER (PARTITION BY nt ORDER BY val) -1 AS prev
            FROM
                (
                    SELECT
                        level                          AS val,
                        ceil(rownum/3)  as nt /* Grouped in batches of 3 */
                    FROM
                        dual
                        CONNECT BY level <= 10
                )
        )
    GROUP BY
        nt
        CONNECT BY prev = PRIOR curr
    AND nt              = PRIOR nt
        START WITH curr = 1;
    
            NT CONCAT_VAL
    ---------- --------------------------------------------------------------------------------
             1 1,2,3
             2 4,5,6
             3 7,8,9
             4 10
    

    Your code

    SELECT
        nt,
        LTRIM(MAX(SYS_CONNECT_BY_PATH(title_id,',')) KEEP (DENSE_RANK LAST ORDER BY curr),',') AS concat_val
    FROM
        (
            SELECT
                title_id,
                nt,
                ROW_NUMBER () OVER (PARTITion BY nt ORDER BY title_id)   AS curr,
                ROW_NUMBER() OVER (PARTITION BY nt ORDER BY title_id) -1 AS prev
            FROM
                (
                    SELECT
                        title_id,
                        ceil(rownum/25) AS nt /* Grouped in batches of 25 */
                    FROM
                        pack_relation tdpr
                    JOIN annotation fa
                    ON
                        tdpr.package_id = fa.package_id
                    GROUP BY
                        title_id,
                        fa.package_id
                    HAVING
                        COUNT (fa.package_id) < 500
                )
        )
    GROUP BY
        nt
        CONNECT BY prev = PRIOR curr
    AND nt              = PRIOR nt
        START WITH curr = 1;
    
  • Combine several values of rank in a line like comma delimeted string

    Hello

    I have a requirement to combine several values of rank in a line as the comma delimeted string as below

    INDEX_NAME COLUMN_NAME POSITION_COLONNE
    EMP_EMAIL_UK EMAIL 1
    EMP_EMP_ID_PK EMPLOYE_ID 1
    EMP_DEPARTMENT_IX DEPARTMENT_ID 1
    JOB_ID EMP_JOB_IX 1
    EMP_MANAGER_IX MANAGER_ID 1
    EMP_NAME_IX LAST_NAME 1
    EMP_NAME_IX FIRST_NAME 2
    I write in a SQL and the output I need is, for example EMP_NAME_IX LAST_NAME, FIRST_NAME.

    I can't write any function as well.

    http://www.Oracle-base.com/articles/Misc/StringAggregationTechniques.php

    SELECT index_name,
           ltrim(sys_Connect_by_path(column_name, ','), ',') column_names
      FROM (select index_name,
                   column_name,
                   row_number() over(partition by index_name order by column_position) rn
              from all_ind_columns
             WHERE table_owner = 'HR')
     WHERE connect_by_isleaf = 1
     START WITH rn = 1
    CONNECT BY PRIOR rn = rn - 1
           and prior index_name = index_name
    
  • looking for a specific string in a comma separated column

    I have a column of table called content that shows the following values.

    Content ID
    = ====
    1 jkl, abc, def, xyz
    2 jkl
    3 jklm, xyz
    4 abc

    I need to write a sql statement to find all records that has 'jkl', the result I want is 1 and 2. Any suggestions?

    Thank you.

    Something like

      with t1 as (
      select 1 id, 'abc, jkl, def, xyz' content from dual
      union select 2, 'jkl' from dual
      union select 3, 'jklm, xyz' from dual
      union select 4, 'abc' from dual)
      select id
        from t1
      where ', '||content||',' like '%, jkl,%';
    

    You can avoid record 3

    Published by: user8252707 on February 27, 2009 22:26
    I forgot ' % s :)

    Published by: user8252707 on February 27, 2009 22:33
    Now, it should work!

  • Split comma delimited string CONNECT BY Clause

    Hello
    I had a problem by dividing a strings separated by commas into lines.

    I explain the following use cases:

    I have an x in table
    -> create table x (id number, int_status varchar2 (100), c_ref varchar2 (30), s_ref varchar2 (30));

    I inserted values in the table:

    insert into x (id, int_status, c_ref, s_ref) values (1, 'a1, a2, a3, a4 ', 'A',' AS');
    insert into x (id, int_status, c_ref, s_ref) values (1,'b1, b2, b3, b4 ',' B', 'BS');
    insert into x (id, int_status, c_ref, s_ref) values (1,'c1, c2, c3, c4 ", 'C', null);
    insert into x (id, int_status, cust_ref, site_ref) values (1, NULL, would be ', NULL);


    I need to split the int_status separated by commas into individual lines. This means that my result is:

    . What I need or are looking as expected result:
    -----------
    1, has, HAVE, a1
    1, has, HAVE, a2
    1, has, HAVE, a3
    1, has, HAVE, a4
    1, B, BS, b1
    1, B, BS, b2
    1, B, BS, b3
    1, B, BS, b4
    C, 1, null, c1
    C, 1, null, c2
    C, 1, null, c3
    C, 1, null, c4

    I currently have a solution using Regex. But this solution uses the UNIQUE keyword.

    The solution that I currently have:

    Select UNIQUE c_ref, s_ref, regexp_substr (int_status, "[^,] +', 1, level") error_code
    x
    connect regexp_substr (int_status, "[^,] +', 1, level") is not null;


    I need a better solution. Pointers?

    Thank you
    Cherif

    Hi Omar,.

    I mentioned the solution of Odie for similar problem some time ago...
    and in my opinion the easiest to solve your task would be:

    SELECT id,c_ref,s_ref,str error_code
      FROM x_imp,
           XMLTABLE ('ora:tokenize($v, ",")'
                     PASSING int_status AS "v"
                     COLUMNS str VARCHAR2 (12) PATH '.');
    

    output:

    ID     C_REF     S_REF     ERROR_CODE
    1     A     AS     a1
    1     A     AS     a2
    1     A     AS     a3
    1     A     AS     a4
    1     B     BS     b1
    1     B     BS     b2
    1     B     BS     b3
    1     B     BS     b4
    1     C          c1
    1     C          c2
    1     C          c3
    1     C          c4
    

    See you soon,.
    Manik.

Maybe you are looking for