Convert column bounded by lines and use it in a SQL view

Table TABLE_1 has the structure,

CREATE TABLE table_1

(

(10) IDENTIFICATION NUMBER,

LINE_NO NUMBER (10),

CODES VARCHAR2 (100)

)

It has values,

INSERT INTO TABLE_1 VALUES (1, 1, 'ERR101:ERR102');

INSERT INTO TABLE_1 VALUES (1, 2, "ERR103:ERR104:ERR106");

INSERT INTO TABLE_1 VALUES (1, 1, 'ERR105');

INSERT INTO TABLE_1 VALUES (1, 3, 'ERR107:ERR108');

INSERT INTO TABLE_1 VALUES (2,1, ");

INSERT INTO TABLE_1 VALUES (2, 1, 'ERR109:ERR110');

COMMIT;

It has the data,

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

ID |    LINE_NO |         CODES

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

1 1 ERR101:ERR102

1 2 ERR103:ERR104:ERR106

1           1                          ERR105

1 3 ERR107:ERR108

2           1

2 1 ERR109:ERR110

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

I need to create a view that must run on the table TABLE_1 and have the CODES separated column using the delimiter ':' in lines like:

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

ID |    LINE_NO |         CODES

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

1           1                          ERR101

1           1                          ERR102

1           1                          ERR105

1           2                          ERR103

1           2                          ERR104

1           2                          ERR106

1           3                          ERR107

1           3                          ERR108

2           1

2           1                          ERR109

2           1                          ERR110

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

Help with the changes.

Thanks in advance

Well, Yes, split the data will take time, and it's one of the problems do not store data correctly in the first place.

Ideally, you want to correct the data model and process your existing data (which takes time) to enter in the new structure, so you can query the data more easily and correctly.

Apart from that your request is not correct for multiple lines of data being split, it must be more like...

SQL > ed
A written file afiedt.buf

1 select id
2, line_no
3, codes
4, level as an input
5, regexp_substr(codes,'[^:]+',1,level) as code
6 of table_1
7 plug by id = prior id
8 and line_no = line_no prior
9 and codes = prior codes
10 and regexp_substr(codes,'[^:]+',1,level) is not null
11 * and prior sys_guid() is not null
SQL > /.

CODE ENTRY CODES ID LINE_NO
---------- ---------- ------------------------------ ---------- -----------------------
1 1 ERR101:ERR102 1 ERR101
1 1 ERR101:ERR102 2 ERR102
1 1 ERR105 1 ERR105
1 2 ERR103:ERR104:ERR106 1 ERR103
1 2 ERR103:ERR104:ERR106 2 ERR104
1 2 ERR103:ERR104:ERR106 3 ERR106
3 1 ERR107:ERR108 1 ERR107
3 1 ERR107:ERR108 2 ERR108
2 1 ERR109:ERR110 1 ERR109
2 1 ERR109:ERR110 2 ERR110
2          1                                         1

11 selected lines.

Tags: Database

Similar Questions

  • Works with tables/columns of the lines and the parameter names... syntax help

    I am trying to create a function that returns the distinct value and counts of a user defined schema/table/column.

    The code below defines a [stats_on_column_obj] object type and creates a single table of this type [stats_on_column_tab].

    The function is supposed to take three input variables: p_schema_name, nom_table_p, p_column_name and return an array (above).

    I can hardcode a select into (the)... but once I try to convert it into settings & immediate exec I'm stuck. The red section is where the problem is (I think).

    Oracle 10g.

    Stats_on_column_obj CREATE TYPE IS OBJECT (

    COL_VAL VARCHAR2 (500),

    NUMBER OF COL_VAL_CNT (7)

    );

    CREATE TYPE Stats_on_column_tab IS TABLE OF stats_on_column_obj;


    FUNCTION to CREATE or REPLACE get_STATS_ON_COLUMN

    (

    p_schema_name IN varchar2,

    nom_table_p IN varchar2,

    p_column_name IN varchar2

    )

    RETURN STATS_ON_COLUMN_tab

    IS

    l_STATS_ON_COLUMN_tab STATS_ON_COLUMN_tab: = STATS_ON_COLUMN_tab ();

    n INTEGER: = 0;

    str_select_tbl varchar2 (5000);

    BEGIN

    str_select_tbl: = 'SELECT'. p_column_name |' as col_val, count (*) as col_val_cnt FROM ' | p_schema_name |'. ' || nom_table_p: ' group of ' | p_column_name;

    FOR r IN (str_select_tbl)

    LOOP

    l_STATS_ON_COLUMN_tab. EXTEND;

    n: = n + 1;

    l_STATS_ON_COLUMN_tab (n): = STATS_ON_COLUMN_obj (r.col_val, r.col_val_cnt);

    END LOOP;

    RETURN l_STATS_ON_COLUMN_tab;

    END;

    /

    [Error] PLS-00103 (124:4): PLS-00103: encountered the symbol "LOOP" when expecting one of the following numbers: * & - + / at rem rest mod.. < an exponent (*) > | multiset year DAY_

    [Error] PLS-00103 (126:9): PLS-00103: encountered the symbol "=" when expected in the following way: constant exception < an ID > < a between double quote delimited identifiers > double Ref table Fedya Chariot of time timestam

    [Error] PLS-00103 (127:29): PLS-00103: encountered the symbol "

    [Error] PLS-00103 (128:4): PLS-00103: encountered the symbol "END" when waiting for one of the following numbers: begin function package pragma procedure subtype type use < an ID > < a double quote delimited identifier > form

    SELECT * FROM TABLE (get_STATS_ON_COLUMN ('SCHEMAS_X', 'TABLE_X', 'COLUMN_X'));

    Scott@ORCL > CREATE OR REPLACE
    FUNCTION get_STATS_ON_COLUMN () 2
    3 p_schema_name IN varchar2,
    4 nom_table_p IN varchar2,
    5 p_column_name IN varchar2
    6                                )
    7 STATS_ON_COLUMN_tab of RETURN
    8 EAST
    9 v_STATS_ON_COLUMN_tab STATS_ON_COLUMN_tab: = STATS_ON_COLUMN_tab ();
    10 v_n INTEGER: = 0;
    11 v_str_select_tbl VARCHAR2 (5000);
    BEGIN 12
    13 v_str_select_tbl: = ' SELECT stats_on_column_obj (' | p_column_name |) ', Count OF ' |
    14 p_schema_name | '.' || nom_table_p | "Group of" | p_column_name;
    15 v_str_select_tbl EXECUTE IMMEDIATE
    COLLECTION IN BULK 16
    17 IN v_STATS_ON_COLUMN_tab;
    18 RETURN v_STATS_ON_COLUMN_tab;
    END 19;
    20.

    The function is created.

    Scott@ORCL > select *.
    2 from table)
    (3 get_STATS_ON_COLUMN)
    4                                            'SCOTT',
    5                                            'EMP',
    6                                            'JOB'
    7                                           )
    8                       )
    9.

    COL_VAL COL_VAL_CNT
    -------------------- -----------
    CLERK                          4
    SELLER 4
    PRESIDENT 1
    MANAGER 3
    ANALYST 2

    Scott@ORCL >

    Or better change function in the pipeline.

    SY.

  • Selection of parts and columns, or entire lines and apply the character style

    I am trying to apply character styles to certain parts/whole rows and columns.

    I can change individual cells with the following code...

    table = app.selection[0];
    if (table.hasOwnProperty("baseline")) table = table.parent;
    if (table instanceof Cell) table = table.parent;
    if (table instanceof Column) table = table.parent;
    if (table instanceof Row) table = table.parent;
    if (table instanceof Table)
    
    {
     table.rows[0].cells[6].texts[0].appliedCharacterStyle = "none report";
     }
    

    ... but when I try to select an entire line, I get the error 'Object does not support property or method' texts. "" "When I try one of the following two codes.

    {
     table.rows[0].cells.texts.appliedCharacterStyle = "none report";
     }
    

    {
     table.rows[0].cells.appliedCharacterStyle = "none report";
     }
    

    Anyone know how I can do the following?

    1. Select any row (or column) and apply the character style

    2. Select the last line (regardless of the number of rows in the table) and apply the character style

    3. apply the character style to specific columns (with theexception of the cells of two albums)

    Thank you!

    Hello

    Change this line:

    table.columns[a].cells.itemByRange(2,-1).texts.everyItem().appliedCharacterStyle = "chart orange";
    

    for the first 2 rows in each column

    Jarek

  • convert variables to hex values and show them in a hexadecimal view

    I send hexadecimal a sony evi-d100 cam controls. The command must be a hexadecimal string. But the cam accept only the commands that are displayed in hexadecimal.

    It works very well with constant strings. But for my project, I need pipes also variable strings. I can convert these variables to a hexadecimal string of tone values, but are not properly shown in a hexagonal section. for example, I have converted 100 (decimal) value in hex is 64. But the value hex display of the chain is always 3634. And it is not accepted by my cam to 64.

    But why it works with string constants?

    Thanks for help

    Mark


  • Convert a single column into multiple lines

    Hi people,

    I have a task to display a single column into multiple lines (for use in LOV)

    For Ex:

    The column consistes of value such as 98,78,67,68,34,90. -It's a unique column values where none of the values can be ' number that is separated by commas

    Then we must view it as

    98
    78
    67
    68
    34
    90
    -under the number of lines (no lines can be ' do not number).

    Thanks in advance

    Try this...

    SQL> ed
    Wrote file afiedt.buf
    
      1  select regexp_substr('98,78,67,68,34,90', '[^,]+',1,level) Value
      2    from dual
      3*   connect by level <= regexp_count('98,78,67,68,34,90',',') + 1
    SQL> /
    
    VALUE
    -----------------
    98
    78
    67
    68
    34
    90
    
    6 rows selected.
    

    Thank you!

  • Conversion of column to the lines

    Hello
    I'm currently building and SQL to convert columns from several lines to all lines - see below the test data and the expected result:
    CREATE TABLE XX_TEST (NAME VARCHAR2 (10), A1 VARCHAR2 (10), A2 VARCHAR2 (10), A3 VARCHAR2 (10), A4 VARCHAR2 (10), A5 VARCHAR2 (10));
    INSERT INTO XX_TEST VALUES('LIST','A','B','C','D','E');
    INSERT INTO XX_TEST VALUES('L1','1',,'3',,);
    INSERT INTO XX_TEST VALUES('L2','1','5','4',,);
    ENGAGE
    SELECT * FROM XX_TEST;

    Expected result:
    NAME is the table XX_TEST column, but the COLUMN and the VALUE are converted to lines - columns

    NAME THE COLUMN VALUE
    L1 A1 1
    L1 A2 NULL
    L1 A3 3
    L1 A4 NULL
    L1 A5 NULL
    L2 A1 1
    L2 A2 5
    L2 A3 4
    L2 NULL A4
    L2 A5 NULL

    Thank you
    BS

    Hello

    user13409900 wrote:
    Thank you Alex and Frank,

    Don't foget Aketi!

    The two ways are really good and functional in my situation.
    I apologize for not giving version: I'm on 11g so I think that can use Unpivot. It would be really more faster (performance given the volume of data) to use unpivot characteristic of 11 g?

    If there is no significant difference, whereas I think is that SELECT... UNPIVOT would be faster. It is purely a guess. It depends on several factors, including your data, your index and your machine. I don't have access to one of them.

    Try both ways and compare performance. (Compare the results, too, to check that the two qiueries are really doing the same thing).
    If you need help, see this thread:
    HOW to: Validate a query of SQL statement tuning - model showing

    I've never used before unpivot.

    This sounds like a good opportunity to learn.

  • Photomerge produces white lines when using RAW (PEF) but not TIFF

    I just started using PS CC (Mac, v14.1.2) and tried Photomerge with a set of 40 (4 lines, 10 passes) raw (Pentax PEF format) images, with the result picture 0.3 gigapixels.

    When I sewed them by Photomerge, I see thin white lines in the melting points.

    I had activated all 3 options (mix together tile images, deletion, geometric distortion correction), using cylindrical available.

    When I have everything first to convert the PEF at TIFF and use Photomerge with the same options, there is no white lines.

    An example of the wrong exit:

    Screen Shot 2013-11-30 at 17.49.29.PNG

    These unwanted lines are, of course, on the edges where the images are meet.

    In addition, when you use only a few images (2 x 2 or 3 x 3 or even 4 x 5), I don't get this effect.

    I noticed that when you use fewer images, edges of the layer masks are not straight - but they are when I see this problem. This suggests that, at some point, the merge operation gets overwhelmed and going on to a simple algorithm, which in turn has this 'bug' with RAW images, apparently.

    Is this a known problem, and is there a way to get this working right with that, many images RAW/PEF?

    Trevor,

    The options that I have used with PhotoMerge are mentioned in my first post.

    'Automatic merging of layers' with the option 'Seemless '.... "necessary checked much more disk space (scratch) than the PhotoMerge operation (PhotoMerge became as well as about 35 GB, while the automatic layer merging was not yet satisfied with 60 GB of free disk space).

    And your proposal was right! With the operation of auto-merge layers, lines appear no more!

    This result, as well as the greatest need of memory, gives to think that the operation of PhotoMerge does not use the option "smooth", but it should offer this option, or even automatically use when there RAW files as input.

    In any case, thanks for solving this.

  • Some of the columns to pivot lines

    Hello

    I need some columns to pivot lines and have the remaining columns in the result.

    At this point, I have already made a subquery to gather data and to keep the running time down I prefer not to do it again as a UNION would require.

    A row
    CUST TEST_DATE TEST_TYPE1 TEST_TYPE2 TEST_TYPE3
    1 20 MARCH 09 AA BB CC

    Result rows
    CUST TEST_DATE TEST_TYPE
    1 AA 20 MARCH 09
    1 BB 20 MARCH 09
    1 BB 20 MARCH 09

    Suggestions please?

    Thanks in advance for your help,

    Lou
    with t as (
               select 1 cust,to_date('20-MAR-09','dd-mon-yy') test_date,'AA' test_type1,'BB' test_type2,'CC' test_type3 from dual
              )
    select  cust,
            test_date,
            case lvl
              when 1 then test_type1
              when 3 then test_type2
              else test_type3
            end test_type
      from  t,
            (select level lvl from dual connect by level <= 3)
      order by cust,
               test_date,
               test_type
    /
    
          CUST TEST_DATE TE
    ---------- --------- --
             1 20-MAR-09 AA
             1 20-MAR-09 BB
             1 20-MAR-09 CC
    
    SQL> 
    

    SY.

  • 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.

  • 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.

  • How to get multiple records in a line and a different column

    Hi all

    I am using oracle database 11g

    and I have a two table table_1, table_2
    table_1 has columns

    emp_no
    first name
    middle_name
    last_name
    E-mail

    and table_2 have columns
    emp_no
    phone_type
    Phone_Number

    and having entires

    emp_no phone_type phone_number
    1001 MOB 9451421452
    1001 WEMG 235153654
    1001 652341536 EMG
    1002 MOB 9987526312
    1003 WEMG 5332621456
    1004 59612356 EMG

    Now I want the output of values with the MOB or WEMG phone type in a single line with different columns

    emp_no first_name last_name middle_name officeno mobile e-mail

    1001 score null k 9451421452 235153654 [email protected]
    1002 chagneau gary [email protected] 9987526312 null
    1003 dany craig [email protected] 5332621456 null null
    1004 donald finn sian [email protected] null null



    Can I have any input to achieve this?


    Concerning

    $sid

    Hi Sid,

    Under query will be help for you...

    SELECT tab1.emp_no
    *, first name *.
    *, middle_name *.
    *, last_name *.
    *, email *.
    *, mobile t2.phone_number *.
    *, t3.phone_number officeno *.
    OF tab1
    *, (SELECT Emp_no *)
    *, phone_number *.
    Of THE tab2
    WHERE phone_type = "MOB") t2
    *, (SELECT Emp_no *)
    *, phone_number *.
    Of THE tab2
    WHERE phone_type = "WEMG") t3
    WHERE tab1.emp_no = t3.emp_no
    AND tab1.emp_no = t2.emp_no;

    Thnks,
    cveluri

  • I do my job to the computer on a MAC computer. I want to create a document using Pages and then convert the document to PDF and send a group email. I want to send the PDF using the pdf for each receiver icon must click the icon to open t

    I do my job to the computer on a MAC book PRO. I want to create a document using Pages and then convert the document to PDF and send a group email. I want to send the PDF using the pdf for each receiver icon must click the icon to open the document. My problem is the document does not show the icon, but rather the document is already open. I spoke with 2 Apple. 'Experts' care and can help me. Can someone tell me what to do?

    It's a question of how the recipients e-mail programs deal with attachments. Many e-mail programs will open all the files they can handle, including files jpg and PDF, by default, and if the recipient has not changed that there is nothing you can do about it. The only solution is to the compress first, then it will be delivered as an attachment, allowing the recipient to decompress and open it.

  • How to dynamically add any control (digital button, boolean) to control the line and selected column

    Hello

    How to add a control (digital button, boolean) dynamically in control instead of lines and columns selected. Please suggest the idea or no matter what example code you have please share with me...

    Thank you

    Vieu

    Essentially, that's what you're looking for:

    Please note that you have to account border sizes and the label of the control so that the code does not work right out of the box. You should also check for the height and width of column and if the position is valid at all before moving around the control.

    Norbert

  • How to read a text file that is longer than 65536 lines and write the data to a spreadsheet Excel and the data to write in a new column, once exhausted 65536 cells in a column?

    I have data to the basic generic text file format that must be converted into Excel spreadsheet format.  The data are much longer than 65536 rows and in my code, I was not able to find a way to see the data in the next column.  Currently, the conversion is done manually and generates an Excel file which has a total of 30-40 complete columns of data.  Any suggestions would be greatly appreciated.

    Thank you

    Darrick

    Here is a possible solution to the (potential) problem. Convert an array of strings and erase the data before writing to the file

Maybe you are looking for