string separated by commas of lines and columns

Hello

I have several channels, for example

There are only numbers

the length of the numbers is different as well as the length of the string to a number is always different

Row1 111,112,113,114

row2 22.23

row3 1,2,3,4,5

How can I turn in the following

col1 col2

111 112,113,114

112 111,113,114

113 111,112,114

114 111,112,113

22 23

23 22

1 2,3,4,5

and so on...

None righteous, I missed the fact that the OP asked for the numbers to be removed from the list...

SQL > ed

A written file afiedt.buf

1 with t as (select ' 111,112,113,114' in the neck of double union all

2 Select "22.23 ' in any union.

3 select "1,2,3,4,5' double '.

4            )

5  --

6 end of test data

7  --

8. Select level n

9, trim ("," regexp_replace (col,'(.*?) (^|,)'|| regexp_substr (col, ' [^,] +', 1, level). » (,|$) (.*?) (($', '\1,\4')) in the neck

regexp_substr 10, (col, ' [^,] +', 1, level) in the framework

11 t

12 connect by prior col = col

13 and level<= regexp_count(col,="">

14 * and prior sys_guid() is not null

SQL > /.

COL N PARTY

---------- --------------- ---------------

1 2,3,4,5 1

2 2 1,3,4,5

3 3 1,2,4,5

4 4 1,2,3,5

5 5 1,2,3,4

1 112,113,114 111

2 111,113,114 112

3 111,112,114 113

4 111,112,113 114

1 23 22

2 22 23

(regular expressions less performance best, wise)

Please also note that you should not ask for your message to be marked as correct/good which is considered to be "begging for points" and is against the forum rules.

Tags: Database

Similar Questions

  • String separated by commas as input and display output

    Hello

    I have a requirement that I have to take a string separated by commas as entry (may be in a table?) and display the output.

    For example, executions should be like this:

    Please enter the string separated by commas:

    A, B, C, D (entries of the user)

    Output must be

    You entered:
    A
    B
    C
    D


    How can do us in PL/SQL?

    Thank you
    Pramod
    /* Formatted on 2012/06/12 09:22 (Formatter Plus v4.8.8) */
    SELECT     REGEXP_SUBSTR ('A,B,C,D', '[^,]+', 1, LEVEL) AS re
          FROM DUAL
    CONNECT BY LEVEL <= NVL (LENGTH (REGEXP_REPLACE ('A,B,C,D', '[^,]', NULL)), 0) + 1;
    
  • have a column that has values separated by commas... and I'm s

    Have a column that has values separated by commas... and I'm trying to separate.
    I am trying to create a stored procedure... The 11g xe version. apex .and version 4...
    Here is the part of the code... I can't do a procedure. causes my intervention consist with the clause...

    create or replace procedure ins_adv_invoice
    (mmagazine_no number, madvtno number, missueno number, varchar2, varchar2, varchar2 msalesman_code mpagenumber msection)
    is

    cursor cx is with testa as
    (select name of the advertiser pagenumber)
    Select regexp_substr (pagenumber, ' [^,] +', 1, rownum) result
    the advertiser
    connect by level < = length (regexp_replace (pagenumber, ' [^,] + "")) + 1
    where advt_no = madvtno;


    Start
    for xxx CX
    loop
    insert into adv_invoice (magazine_no, advtno, adissue, section, opinion, salesman_code)
    values (mmagazine_no, madvtno, missueno, msection, xxx.result, msalesman_code);

    end loop;

    end;


    But when I run the present... it creates no procedure. . I receive he following error...
    LINE/COL ERROR
    -------- ----------------------------------------------------
    5/14 PL/SQL: statement ignored
    9/69 PL/SQL: ORA-00933: SQL not correctly completed command
    SQL >
    Still not able to understand... If anyone can help...
    Thank you

    Change the query to swap the last two lines:

    ...
    cursor cx is with testa as
    (select pagenumber name from advertiser)
    select regexp_substr(pagenumber, '[^,]+', 1, rownum) result
    from advertiser
    where advt_no = madvtno
    connect by level <= length(regexp_replace(pagenumber, '[^,]+')) + 1;
    ...
    
  • How to split string separated by commas and pass to the clause of the select statement

    Referring to article How to divide string separated by commas, then pass to clause of a select statement, tquery that there the following plan:

    Query1:

    select * from emp where ename in (
        select regexp_substr('SMITH,ALLEN,WARD,JONES','[^,]+', 1, level) from dual
        connect by regexp_substr('SMITH,ALLEN,WARD,JONES', '[^,]+', 1, level) is not null );
    

    Base1:

    Plan hash value: 4242290184
    
    
    --------------------------------------------------------------------------------------------
    | Id  | Operation                       | Name     | Rows  | Bytes | Cost (%CPU)| Time     |
    --------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                |          |     1 |   133 |     7  (29)| 00:00:01 |
    |*  1 |  HASH JOIN                      |          |     1 |   133 |     7  (29)| 00:00:01 |
    |   2 |   VIEW                          | VW_NSO_1 |     1 |    46 |     3  (34)| 00:00:01 |
    |   3 |    HASH UNIQUE                  |          |     1 |       |     3  (34)| 00:00:01 |
    |*  4 |     CONNECT BY WITHOUT FILTERING|          |       |       |            |          |
    |   5 |      FAST DUAL                  |          |     1 |       |     2   (0)| 00:00:01 |
    |   6 |   TABLE ACCESS FULL             | EMP      |    14 |  1218 |     3   (0)| 00:00:01 |
    --------------------------------------------------------------------------------------------
    
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
    
       1 - access("ENAME"="$nso_col_1")
       4 - filter( REGEXP_SUBSTR ('SMITH,ALLEN,WARD,JONES','[^,]+',1,LEVEL) IS NOT NULL)
    

    However, the following query generates the plan I want:

    Query2:

    select * from emp where ename in ('SMITH','ALLEN','WARD','JONES');
    

    Plan2:

    Plan hash value: 3956160932
    
    
    --------------------------------------------------------------------------
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    --------------------------------------------------------------------------
    |   0 | SELECT STATEMENT  |      |     4 |   348 |     3   (0)| 00:00:01 |
    |*  1 |  TABLE ACCESS FULL| EMP  |     4 |   348 |     3   (0)| 00:00:01 |
    --------------------------------------------------------------------------
    
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
    
       1 - filter("ENAME"='ALLEN' OR "ENAME"='JONES' OR "ENAME"='SMITH' OR
                  "ENAME"='WARD')
    

    Can I change the query1 query for plan2?

    As Juliet was mentioned in the first SQL that you generate from the ENAME list that you must pass in the IN clause when executing. But in the second SQL, it passed as a static value. So first SQL must do more work. So you see a different execution plan.

    But this is a work around to get what you are looking for. But I can't say it's a foolproof method. But anyway here you go.

    SQL > var ename_list varchar2 (100)
    SQL > exec: ename_list: = 'SMITH, ALLEN, WARD, JONES ';

    PL/SQL procedure successfully completed.

    SQL > select *.
    2 of PEM
    where the 3 «,» | : ename_list | ',' like '%', | Ename | ',%';

    EMPNO, ENAME, JOB HIREDATE DEPTNO ID COM SAL MGR
    ---------- ------ --------- ---------- --------- ---------- ---------- ---------- ----------
    7369 SMITH COMMITTED 7902 2975 2 APRIL 81 0 20
    7499 ALLEN 7698 1600 20 FEBRUARY SALESMAN 81 300 30
    7521 WARD 7698 1250 22 FEBRUARY SALESMAN 81 500 30
    7566 JONES MANAGER 7839 2975 2 APRIL 81 0 20

    SQL > select * from table (dbms_xplan.display_cursor);

    PLAN_TABLE_OUTPUT
    -------------------------------------------------------------------------------------------------------
    SQL_ID, 848zhvbvgf7d6, number of children 0
    -------------------------------------
    Select * from emp where «,» | : ename_list | ',' like '%', | Ename
    || ',%'

    Hash value of plan: 2872589290

    --------------------------------------------------------------------------
    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |
    --------------------------------------------------------------------------
    |   0 | SELECT STATEMENT |      |       |       |     2 (100) |          |
    |*  1 |  TABLE ACCESS FULL | EMP |     1.    38.     2 (0) | 00:00:01 |
    --------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):
    ---------------------------------------------------

    1 - filter(','||:ENAME_LIST||',' LIKE '%,'||") ENAME "|", %')

    19 selected lines.

    SQL >

  • How to write express line and column of the tables headers to a file

    HI guys, I work with that express table and display data using the express table. What I want to do, is that when I press save button results data in the specific table must be written to a text file. I am able to write the text file, but only the data is written. Y at - there a possiblity that I can also write lines and column headers and the data in the text file. Kindly guide me in this regard as soon as possible. I enclose the image also. Please watch this and guide me.

    Cordially Ehtisham Safdar.

    Hello

    Sorry for the late reply. Here is the VI, I hope it works for you. Rather than each element of the index and the addition of the row header, take advantage of the available icons and play with the nodes of property for a good solution.

    Concerning

    Gaze

  • I still have not found "help" to tell me how to remove all the lines and columns beyond those needed for my spreadsheet.

    I used several worksheets.  More allows me to specify the rows/columns and then delete them.  This is to remove all the lines/columns beyond those set up and formatted for my spreadsheet.   I tried many ways to remove all additional lines/columns, but without success.  I even took the time to scroll down/on to highlight all the unnecessary lines and columns, but they do not remove it.
    Any suggestions?  I used spreadsheets most allow me to specify the number of rows/columns for my worksheet

    You can ask your question in the office | Excel Forum because it is not really a problem of Windows XP performance and maintenance.

    Office | Excel

    http://answers.Microsoft.com/en-us/Office/Forum/Excel

    Also, providing specific information may help to get a faster response or better, such as the version of Office or Excel? version of Windows XP? Home, Pro, 32-bit or 64-bit.

    I hope this helps.

  • Convert the string separated by commas in the rows

    Dear gurus,

    I want to convert the string separated by commas in the rows to insert in the collection.

    for example, the string 1234,2323,23232,2343,34234
    Higher up in the chain must be converted to ranks in order to insert into the table or the collection

    Thanks in advance
    Sanjeev

    String in rows separated to convert the comma.

    with t
    as
    (
    select '1234,2323,23232,2343,34234' as txt from dual
    )
    select REGEXP_SUBSTR (txt, '[^,]+', 1, level)
      from t
     connect by level <= length(regexp_replace(txt,'[^,]*'))+1
    
  • With the help of a string of separated by commas as lines

    HT a column in which I store the name separated by commas, I have to show them that the lines in a report...
    Help, please

    Check out this link...

    http://nimishgarg.blogspot.com/2009/12/Oracle-SQL-use-comma-seprated-string-to.html

  • divide the string separated by commas into columns

    Hello
    I have the following string
    str := 'abcd,123,defoifcd,87765'
    The above string must be divided into 4 different columns

    How can I achieve that

    Thank you

    Hello

    Use REGEXP_SUBSTR:

    SELECT  REGEXP_SUBSTR (str, '[^,]+', 1, 1)    AS part_1
    ,       REGEXP_SUBSTR (str, '[^,]+', 1, 2)    AS part_2
    ,       REGEXP_SUBSTR (str, '[^,]+', 1, 3)    AS part_3
    ,       REGEXP_SUBSTR (str, '[^,]+', 1, 4)    AS part_4
    FROM    table_x
    ;
    

    Str can contain foul? For example, you can have a string like ' foo, bar ", where you want to count part_2 and part_3 as NULL and 'bar' is part_4? If so:

    SELECT  RTRIM (REGEXP_SUBSTR (str, '[^,]*,', 1, 1), ',')    AS part_1
    ,       RTRIM (REGEXP_SUBSTR (str, '[^,]*,', 1, 2), ',')    AS part_2
    ,       RTRIM (REGEXP_SUBSTR (str, '[^,]*,', 1, 3), ',')    AS part_3
    ,       LTRIM (REGEXP_SUBSTR (str, ',[^,]*', 1, 3), ',')    AS part_4
    FROM    table_x
    ;
    

    Published by: Frank Kulash, February 14, 2012 08:46

  • Value separated by commas in a table column to get each field separtely?

    Hello

    I have the table that a column has values separated by commas in it. This table is populated using SQL LOADER, which is staging table.

    I need to retrieve the records of these values separated by commas.

    format of. CSV file is as -

    A separate file of pipes.

    DHCP-1-1-1. WNLB-CMTS-01-1,WNLB-CMTS-02-2|

    DHCP-1-1-2. WNLB-CMTS-03-3,WNLB-CMTS-04-4,WNLB-CMTS-05-5|

    DHCP-1-1-3. WNLB-CMTS-01-1.

    DHCP-1-1-4. WNLB-CMTS-05-8,WNLB-CMTS-05-6,WNLB-CMTS-05-0,WNLB-CMTS-03-3|

    DHCP-1-1-5 | WNLB-CMTS-02-2,WNLB-CMTS-04-4,WNLB-CMTS-05-7|

    CREATE TABLE link_data (dhcp_token VARCHAR2 (30), cmts_to_add VARCHAR2 (200), cmts_to_remove VARCHAR2 (200));

    insert into link_data values ('dhcp-1-1-1','wnlb-cmts-01-1,wnlb-cmts-02-2',null);

    insert into link_data values ('dhcp-1-1-2','wnlb-cmts-03-3,wnlb-cmts-04-4,wnlb-cmts-05-5',null);

    insert into link_data values ('dhcp-1-1-3','wnlb-cmts-01-1',null);

    insert into link_data values ('dhcp-1-1-4','wnlb-cmts-05-8,wnlb-cmts-05-6,wnlb-cmts-05-0,wnlb-cmts-03-3',null);

    insert into link_data values ('dhcp-1-1-5','wnlb-cmts-02-2,wnlb-cmts-04-4,wnlb-cmts-05-7',null);

    Here the cmts_to_add column has comma separted

    I need values such as -.

    > for wnlb-cmts-01-1,wnlb-cmts-02-2 > > wnlb-CMTS-01-1

    > > wnlb-CMTS-02-2

    > for wnlb-cmts-03-3,wnlb-cmts-04-4,wnlb-cmts-05-5 > > wnlb-CMTS-03-3

    > > wnlb-CMTS-04-4

    > > wnlb-CMTS-05-5

    And so on...

    I do this because it's the staging table and I load data into the main tables using this table.

    This second field contain different values as the simple comma-delimited string.

    I need to write a PLSQL block to insert into the main table after checking as if dhcp-1-1-1 and wnlb-CMTS-01-1 is present in the main table so not to introduce other insert a new record.

    To meet this requirement, I need to get the distinct value of the cmts_to_add column to insert into DB.

    the value will be inserted as dhcp-1-1-1_TO_wnlb-cmts-01-1 and dhcp-1-1-1_TO_wnlb-cmts-02-2 for the first row of the array of link_data.

    The process will also be same for the rest of the lines.

    I use the function substrt and instr for this problem, but its does not work.

    declare

    cursor c_link is select * from link_data.

    l_rec_link link_data % rowtype;

    l_dhcp varchar2 (30);

    l_cmts varchar2 (20000);

    l_cmts_1 varchar2 (32000);

    Start

    Open c_link;

    loop

    extract the c_link in l_rec_link;

    l_cmts: = l_rec_link.cmts_to_add;

    loop

    l_cmts_1: = substr (l_cmts, 1, instr(l_cmts,',')-1);

    dbms_output.put_line (l_cmts_1);

    end loop;

    dbms_output.put_line(l_dhcp||) e '|| l_cmts);

    When the output c_link % notfound;

    end loop;

    exception

    while others then

    Dbms_output.put_line ('ERROR' |) SQLERRM);

    end;

    Its a peusdo code I write, but it also gives me the wrong answer it gives me error ORA-20000: ORU-10027: buffer overflow, limit of 20000 bytes

    I am using-

    Oracle Database 11 g Enterprise Edition Release 11.2.0.1.0 - 64 bit Production

    Please tell me if my problem isn't clear!

    Hello

    little 'trick': Add a comma at the end of the chain... So it's easier to deal with the fact that there are zero, one, or N components...

    CREATE TABLE link_data (dhcp_token VARCHAR2 (30), cmts_to_add VARCHAR2 (200), cmts_to_remove VARCHAR2 (200));
    insert into link_data values ('dhcp-1-1-1','wnlb-cmts-01-1,wnlb-cmts-02-2',null);
    insert into link_data values ('dhcp-1-1-2','wnlb-cmts-03-3,wnlb-cmts-04-4,wnlb-cmts-05-5',null);
    insert into link_data values ('dhcp-1-1-3','wnlb-cmts-01-1',null);
    insert into link_data values ('dhcp-1-1-4','wnlb-cmts-05-8,wnlb-cmts-05-6,wnlb-cmts-05-0,wnlb-cmts-03-3',null);
    insert into link_data values ('dhcp-1-1-5','wnlb-cmts-02-2,wnlb-cmts-04-4,wnlb-cmts-05-7',null);
    COMMIT;

    SET SERVEROUT ON
    DECLARE
    l_cmts VARCHAR2 (200 CHAR);
    l_cmts_1 VARCHAR2 (200 CHAR);
    BEGIN
    FOR r IN (SELECT dhcp_token, cmts_to_add |) ',' cmts
    OF link_data
    )
    LOOP
    l_cmts: = r.cmts;
    l_cmts_1: = SUBSTR (l_cmts, 1, INSTR (l_cmts, ",") - 1);
    While l_cmts_1 IS NOT NULL
    LOOP
    DBMS_OUTPUT. Put_line (r.dhcp_token |) '|' || l_cmts_1);
    l_cmts: = SUBSTR (l_cmts, INSTR (l_cmts, ",") + 1);
    l_cmts_1: = SUBSTR (l_cmts, 1, INSTR (l_cmts, ",") - 1);
    END LOOP;
    END LOOP;
    END;
    /
    DHCP-1-1-1. WNLB-CMTS-01-1
    DHCP-1-1-1. WNLB-CMTS-02-2
    DHCP-1-1-2. WNLB-CMTS-03-3
    DHCP-1-1-2. WNLB-CMTS-04-4
    DHCP-1-1-2. WNLB-CMTS-05-5
    DHCP-1-1-3. WNLB-CMTS-01-1
    DHCP-1-1-4. WNLB-CMTS-05-8
    DHCP-1-1-4. WNLB-CMTS-05-6
    DHCP-1-1-4. WNLB-CMTS-05-0
    DHCP-1-1-4. WNLB-CMTS-03-3
    DHCP-1-1-5 | WNLB-CMTS-02-2
    DHCP-1-1-5 | WNLB-CMTS-04-4
    DHCP-1-1-5 | WNLB-CMTS-05-7

    Best regards

    Bruno Vroman.

  • Build the string separated by commas in query with Expression box sub

    Oracle 10g on Windows XP

    Consider the following query:

    Select batch_id, tr state_tag_seq where request_type in (select case WHEN PX = 'RETURN' AND 'TRANSFER' |) «, » || "PUBLIC TRANSIT"
    WHEN PX = "RFT" THEN "TRANSIT".
    ELSE 'Invalid '.
    END
    OF THE DOUBLE
    ) ;


    In this case, PX is accepted to execution of the user interface.

    I'm having no rows returned (all valid lines matching in DB) for the following case assessment

    WHEN PX = 'RETURN' THEN 'TRANSFER '. «, » ||' Transit "(PX when is evaluated to 'RETURN')

    The application works well when it px IS estimated to be "PCR" (as the evaluated expression is just a string ('TRANSIT') single, not separated by commas, as in the other case)

    Hiow do rewrite this query, if it gives a correct result? In other words, I actually build the query string slot, which is assessed by the external when query clause.

    I think it might be a specific way to use quotes in my case expression, but I'm reaching an impasse. Any help is appreciated.

    Thank you
    SR

    You can try

    select batch_id, state_tag_seq
      from tr
     where request_type member of case
                             when px = 'RETURN'
                             then
                              sys.dbms_debug_vc2coll (
                               'TRANSFER',
                               'TRANSIT'
                              )
                             when px = 'RFT'
                             then
                              sys.dbms_debug_vc2coll ('TRANSIT')
                             else
                              sys.dbms_debug_vc2coll ('Invalid')
                             end
    
  • How would add labels to lines and columns of a spreadsheet?

    I got some data of an oscilloscope, which has about 500 lines I want to the label at the time of measurement (1ms, 2ms, 3ms...) and about 10 columns I want to mark it with a corresponding wavelength (800 nm, 805nm, 810nm...). Any idea or links to examples would be appreciated.

    Gregory

    Before you write data in your spreadsheet file, write a line of column names.  Just make a table 1 d of strings with column names.  Write the 1 d array to the worksheet.  If you want labels on each line, you will need to convert your data into strings.  So, you will have a table 2D-string data.  Create a table 1 d of your line labels.  Insert in the table to insert your picture label in the data table, making sure to wire a 0 in the index of the column, not the index of the row.  This will put your labels in the first column.  Then write the 2D table in the spreadsheet file.

  • How to recover the vales separated by commas in the same column in Oracle SQL

    Dear members

    Please give me the solution for the below question

    Oracle table

    Ename product
    A 1,2,3
    B 1,2,3


    Product column has data like this only separated by commas

    Output should be like this.

    Ename, product
    A 1
    A 2
    A 3
    B 1
    B 2
    B 3

    Can we get the output above using just Oracle SQL select statement?
    I tried in Google I got an answer in SQL server, there is something called "Cross apply split" function, I'm not sure in Oracle.

    Welcome to the forum.

    Here is another interesting site, with lots of useful examples:
    http://asktom.Oracle.com/pls/Apex/f?p=100:11:0:P11_QUESTION_ID:2189860818012 #2654179200346949517

    Also, be sure to read the SQL and PL/SQL FAQ:
    http://forums.Oracle.com/forums/Ann.jspa?annID=1535

  • Matrix - vector lines and columns

    M1 (3,2) gives the element of line 3, column 2

    M1 (2) gives the second row of a matrix (as a vector line)

    Is there a way to return a column (other than transpose, store again and using the method above on the transposed matrix)?

    Tim Wessman wrote:

    Assuming that first here...

    Col(M1,1)

    Row(M1,1)

    @ Tim,.

    As Mmmm - created a post on the 39gii and commented on a post on the 39gii, this one is perhaps more likely to be on the 39gii?

    I think that your presumption re - expresses my presumption that the 39gii becomes brother forgot the premium?

    @ Mmmm.

    Try M1 (-c), where C is desired column number. For example M1(-2) for column 2.

  • Download the news lines and columns of a table Cluster

    I have a table with a cluster of 2 elements (string and double). In my application, I use the architecture of State Machine with a Structure of the event. When I click on an item in the table of the bunch, is there a way to retrieve the row and column? I saw the coordinates within the mouse event to the bottom, but I don't think it will work.

    Any ideas?

    How to return the Index of a table of mouse-Select item:

    https://decibel.NI.com/content/docs/doc-6406

Maybe you are looking for

  • update of lollipop 5.0

    I have the tab2 70 a10 and I was wondering if the update is now ok. I'm worried by the negative comments from people. The reviews were similar on the forums involving many different devicesDarren

  • Debugging Win32 from OutputDebugString() messages do not appear in the debugger

    I am using CVI to produce messages from debugging debugger Win32 using OutputDebugString().  However, debugging messages are not appearing in any debugger.  I can see them in the debug output window in CVI, but they do not appear in any debugger (Deb

  • design of circuit problem

    Hello I created a R - 2R ladder network (joint it photo below) to convert digital-to-analog and I used an op amp to amplify the output of the R - 2R ladder somelevel network. The problem here is that I'm not able to generate ouput when I connect the

  • error code 0 x 641 when you try to install KB2686828, KB2656370

    For at least a month, I get a message that the updates are available when I stopped. But they always fail to install, even when I try to do it manually with the firewall off. All Solutions?

  • Sansa Fuze is not recognized by my computer.

    All of a sudden my computer does not recognize my Sansa Fuze. I tried automatic switching to other formats on the "rocket". What can I do else?