Rows into comma separated values

DB version : 11.2
I would like get rows into comma separated values
expected output
rowvalue1,<space>rowvalue2,<space>rowvalue3,<space>rowvalue4,.....Example:
create table test1 (name1 varchar2(10));
insert into test1 values ('JOHN');
insert into test1 values ('YING');
insert into test1 values ('KAREN');
insert into test1 values ('PEDRO');
commit;
SQL> select * from test1;
NAME1
JOHN
YING
KAREN
PEDROHow can I get this to printed as
JOHN, YING, KAREN, PEDRO

Assuming you want them in no particular order
SQL> select listagg(name1, ',') within group (order by rowid) from test1;
LISTAGG(NAME1,',')WITHINGROUP(
JOHN,YING,KAREN,PEDRO

Similar Messages

  • How to convert result rows into comma separated values

    hi,
    Version
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    PL/SQL Release 11.1.0.7.0 - Production
    CORE     11.1.0.7.0     Production
    TNS for Linux: Version 11.1.0.7.0 - Production
    NLSRTL Version 11.1.0.7.0 - ProductionQuery
    Select distinct prcdr_code from procedure p where P.PRCDR_CTGRY_LKPCD='P' ;
    Output
    PRCDR_CODE
    0001F
    0001T
    0002F
    0002T
    0003F
    0003T
    0004F
    0005F
    0005T
    0006F
    0006T
    0007F
    0007T
    0008F
    0008T
    0009F
    0009T
    000VA
    000VG
    Desired Output
    0001F,0001T,0002F,0002T .................
    My work
    i tried this .....
    Select distinct wm_concat(prcdr_code) as re from procedure p where P.PRCDR_CTGRY_LKPCD='P'  ;
    But i got ORA-22813: operand value exceeds system limits error
    Please help me ..Thanks,
    P Prakash
    Edited by: prakash on Jan 4, 2012 9:05 AM

    Aggregating CLOB's....
    user defined aggregate function can do it...
    create or replace type clobagg_type as object
      text clob,
      static function ODCIAggregateInitialize(sctx in out clobagg_type) return number,
      member function ODCIAggregateIterate(self in out clobagg_type, value in clob) return number,
      member function ODCIAggregateTerminate(self in clobagg_type, returnvalue out clob, flags in number) return number,
      member function ODCIAggregateMerge(self in out clobagg_type, ctx2 in clobagg_type) return number
    create or replace type body clobagg_type is
      static function ODCIAggregateInitialize(sctx in out clobagg_type) return number is
      begin
        sctx := clobagg_type(null) ;
        return ODCIConst.Success ;
      end;
      member function ODCIAggregateIterate(self in out clobagg_type, value in clob) return number is
      begin
        self.text := self.text || value ;
        return ODCIConst.Success;
      end;
      member function ODCIAggregateTerminate(self in clobagg_type, returnvalue out clob, flags in number) return number is
      begin
        returnValue := self.text;
        return ODCIConst.Success;
      end;
      member function ODCIAggregateMerge(self in out clobagg_type, ctx2 in clobagg_type) return number is
      begin
        self.text := self.text || ctx2.text;
        return ODCIConst.Success;
      end;
    end;
    create or replace function clobagg(input clob) return clob
      deterministic
      parallel_enable
      aggregate using clobagg_type;
    SQL> select trim(',' from clobagg(ename||',')) as enames from emp;
    ENAMES
    SMITH,ALLEN,WARD,JONES,MARTIN,BLAKE,CLARK,SCOTT,KING,TURNER,ADAMS,JAMES,FORD,MILLER
    SQL> ed
    Wrote file afiedt.buf
      1  with t as
      2    (select 'PFL' c1, 0 c2,110 c3 from dual union all
      3     select 'LHL', 0 ,111 from dual union all
      4     select 'PHL', 1, 111 from dual union all
      5     select 'CHL', 2, 111 from dual union all
      6     select 'DHL', 0, 112 from dual union all
      7     select 'VHL', 1, 112 from dual union all
      8     select 'CPHL', 0, 114 from dual union all
      9     select 'WDCL', 1, 114 from dual union all
    10     select 'AHL' ,2 ,114 from dual union all
    11     select 'NFDL', 3, 114 from dual)
    12  --
    13  -- end of test data
    14  --
    15  select trim(clobagg(c1||' ')) as c1, c3
    16  from (select * from t order by c3, c2)
    17  group by c3
    18* order by c3
    SQL> /
    C1                                     C3
    PFL                                   110
    LHL CHL PHL                           111
    DHL VHL                               112
    CPHL AHL NFDL WDCL                    114

  • Convert rows into comma seperated values

    Hello I have a question,
    I have a table like this.
    Memid           values
    1                  10
    1                 20
    2                30
    3                50
    3                60
    3               10
    i want to convert it like this
    memid              values
    1 10,20
    2                      30
    3                       50,60,10
    Can you please provide a solution.. 
    Thanks

    SELECT Memid,
    STUFF((SELECT ',' + CAST([values] AS varchar(10))
    FROM Table
    WHERE Memid = t.Memid
    FOR XML PATH(''),TYPE),value('.','varchar(max)'),1,1,'') AS [values]
    FROM (SELECT DISTINCT Memid FROM Table)t
    see
    http://visakhm.blogspot.in/2014/01/rowset-concatenation-with-special.html
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • How can i get all these values in single row with comma separated?

    I have a table "abxx" with column "absg" Number(3)
    which is having following rows
    absg
    1
    3
    56
    232
    43
    436
    23
    677
    545
    367
    xxxxxx No of rows
    How can i get all these values in single row with comma separated?
    Like
    output_absg
    1,3,56,232,43,436,23,677,545,367,..,..,...............
    Can you send the query Plz!

    These all will do the same
    create or replace type string_agg_type as object
    2 (
    3 total varchar2(4000),
    4
    5 static function
    6 ODCIAggregateInitialize(sctx IN OUT string_agg_type )
    7 return number,
    8
    9 member function
    10 ODCIAggregateIterate(self IN OUT string_agg_type ,
    11 value IN varchar2 )
    12 return number,
    13
    14 member function
    15 ODCIAggregateTerminate(self IN string_agg_type,
    16 returnValue OUT varchar2,
    17 flags IN number)
    18 return number,
    19
    20 member function
    21 ODCIAggregateMerge(self IN OUT string_agg_type,
    22 ctx2 IN string_agg_type)
    23 return number
    24 );
    25 /
    create or replace type body string_agg_type
    2 is
    3
    4 static function ODCIAggregateInitialize(sctx IN OUT string_agg_type)
    5 return number
    6 is
    7 begin
    8 sctx := string_agg_type( null );
    9 return ODCIConst.Success;
    10 end;
    11
    12 member function ODCIAggregateIterate(self IN OUT string_agg_type,
    13 value IN varchar2 )
    14 return number
    15 is
    16 begin
    17 self.total := self.total || ',' || value;
    18 return ODCIConst.Success;
    19 end;
    20
    21 member function ODCIAggregateTerminate(self IN string_agg_type,
    22 returnValue OUT varchar2,
    23 flags IN number)
    24 return number
    25 is
    26 begin
    27 returnValue := ltrim(self.total,',');
    28 return ODCIConst.Success;
    29 end;
    30
    31 member function ODCIAggregateMerge(self IN OUT string_agg_type,
    32 ctx2 IN string_agg_type)
    33 return number
    34 is
    35 begin
    36 self.total := self.total || ctx2.total;
    37 return ODCIConst.Success;
    38 end;
    39
    40
    41 end;
    42 /
    Type body created.
    [email protected]>
    [email protected]> CREATE or replace
    2 FUNCTION stragg(input varchar2 )
    3 RETURN varchar2
    4 PARALLEL_ENABLE AGGREGATE USING string_agg_type;
    5 /
    CREATE OR REPLACE FUNCTION get_employees (p_deptno in emp.deptno%TYPE)
    RETURN VARCHAR2
    IS
    l_text VARCHAR2(32767) := NULL;
    BEGIN
    FOR cur_rec IN (SELECT ename FROM emp WHERE deptno = p_deptno) LOOP
    l_text := l_text || ',' || cur_rec.ename;
    END LOOP;
    RETURN LTRIM(l_text, ',');
    END;
    SHOW ERRORS
    The function can then be incorporated into a query as follows.
    COLUMN employees FORMAT A50
    SELECT deptno,
    get_employees(deptno) AS employees
    FROM emp
    GROUP by deptno;
    ###########################################3
    SELECT SUBSTR(STR,2) FROM
    (SELECT SYS_CONNECT_BY_PATH(n,',')
    STR ,LENGTH(SYS_CONNECT_BY_PATH(n,',')) LN
    FROM
    SELECT N,rownum rn from t )
    CONNECT BY rn = PRIOR RN+1
    ORDER BY LN desc )
    WHERE ROWNUM=1
    declare
    str varchar2(32767);
    begin
    for i in (select sal from emp) loop
    str:= str || i.sal ||',' ;
    end loop;
    dbms_output.put_line(str);
    end;
    COLUMN employees FORMAT A50
    SELECT e.deptno,
    get_employees(e.deptno) AS employees
    FROM (SELECT DISTINCT deptno
    FROM emp) e;
    DEPTNO EMPLOYEES
    10 CLARK,KING,MILLER
    20 SMITH,JONES,SCOTT,ADAMS,FORD
    30 ALLEN,WARD,MARTIN,BLAKE,TURNER,JAMES
    CREATE OR REPLACE FUNCTION concatenate_list (p_cursor IN SYS_REFCURSOR)
    RETURN VARCHAR2
    IS
    l_return VARCHAR2(32767);
    l_temp VARCHAR2(32767);
    BEGIN
    LOOP
    FETCH p_cursor
    INTO l_temp;
    EXIT WHEN p_cursor%NOTFOUND;
    l_return := l_return || ',' || l_temp;
    END LOOP;
    RETURN LTRIM(l_return, ',');
    END;
    COLUMN employees FORMAT A50
    SELECT e1.deptno,
    concatenate_list(CURSOR(SELECT e2.ename FROM emp e2 WHERE e2.deptno = e1.deptno)) employees
    FROM emp e1
    GROUP BY e1.deptno;
    DEPTNO EMPLOYEES
    10 CLARK,KING,MILLER
    20 SMITH,JONES,SCOTT,ADAMS,FORD
    30 ALLEN,WARD,MARTIN,BLAKE,TURNER,JAMES
    CREATE OR REPLACE TYPE t_string_agg AS OBJECT
    g_string VARCHAR2(32767),
    STATIC FUNCTION ODCIAggregateInitialize(sctx IN OUT t_string_agg)
    RETURN NUMBER,
    MEMBER FUNCTION ODCIAggregateIterate(self IN OUT t_string_agg,
    value IN VARCHAR2 )
    RETURN NUMBER,
    MEMBER FUNCTION ODCIAggregateTerminate(self IN t_string_agg,
    returnValue OUT VARCHAR2,
    flags IN NUMBER)
    RETURN NUMBER,
    MEMBER FUNCTION ODCIAggregateMerge(self IN OUT t_string_agg,
    ctx2 IN t_string_agg)
    RETURN NUMBER
    SHOW ERRORS
    CREATE OR REPLACE TYPE BODY t_string_agg IS
    STATIC FUNCTION ODCIAggregateInitialize(sctx IN OUT t_string_agg)
    RETURN NUMBER IS
    BEGIN
    sctx := t_string_agg(NULL);
    RETURN ODCIConst.Success;
    END;
    MEMBER FUNCTION ODCIAggregateIterate(self IN OUT t_string_agg,
    value IN VARCHAR2 )
    RETURN NUMBER IS
    BEGIN
    SELF.g_string := self.g_string || ',' || value;
    RETURN ODCIConst.Success;
    END;
    MEMBER FUNCTION ODCIAggregateTerminate(self IN t_string_agg,
    returnValue OUT VARCHAR2,
    flags IN NUMBER)
    RETURN NUMBER IS
    BEGIN
    returnValue := RTRIM(LTRIM(SELF.g_string, ','), ',');
    RETURN ODCIConst.Success;
    END;
    MEMBER FUNCTION ODCIAggregateMerge(self IN OUT t_string_agg,
    ctx2 IN t_string_agg)
    RETURN NUMBER IS
    BEGIN
    SELF.g_string := SELF.g_string || ',' || ctx2.g_string;
    RETURN ODCIConst.Success;
    END;
    END;
    SHOW ERRORS
    CREATE OR REPLACE FUNCTION string_agg (p_input VARCHAR2)
    RETURN VARCHAR2
    PARALLEL_ENABLE AGGREGATE USING t_string_agg;
    /

  • Exporting Metadata (caption information) from JPEGS to a comma separated value (CSV) file

    Here is my dilemma. I am an archivist at an arts organization and we are in the process of digitizing many of our materials to post them on the web and make them available to internet users. One of the principle components of our collection is a large trove of photographs. We have been in the process of digitizing these images and embedding metadata (in the Caption/Description, Author/Photographer and Copyright fields) via PhotoShops File Info command.
    Now I am at a crossroads. We need to extract this metadata and transfer it into a comma separated value form, like an Excel spreadsheet or a FileMakerPro database. I have been told that it is not possible to do this through PhotoShop, that I must run a script through Acrobat or Bridge. I have no clue how to do this. I have been directed to a couple of links.
    First I was directed to this (now dead) link: http://www.barredrocksoftware.com/products.html
    The BSExportMetadata script allegedly exports the metadata from files selected in Adobe's Bridge into a comma separated value (CSV) file suitable for import into Excel, Access and most database programs. It installs as a Bridge menu item making it simple to use. The the Export Metadata script provides you with an easy to use wizard allowing you to select associated information about a set of images that you can then export. This script requires Creative Suite 2 (CS2). This script sounds like it does exactly what I want to do, but unfortunately, it no longer exists.
    Then I found this:
    Arnold Dubin, "Script to Export and Import Keywords and Metadata" #13, 8 Aug 2005 7:23 am
    I tried this procedure, but nothing seemed to happen. I also tried to copy the script into the JAVASCRIPT action option in Acrobat, but I received a message that the script had an error. It also seems to me that this script does not set up a dumping point, that is, a file into which this information will be exported to.
    I am a novice, not a code writer or a programmer/developer. I need a step-by-step explanation of how to implement this filtering of information. We have about 2000 jpeg and tiff files, so I would rather not go through each file and copy and paste this information elsewhere. I need to find out how to create a batch process that will do this procedure for me. Can anyone help?

    Hello -
    Is anyone aware of a tool that will do the above that is available for mac? Everything I've found so far seems to be PC only.
    Any help is appreciated, thanks!

  • Comma Separated Value Taking too Much Time to Execute

    Hi,
    select ES_DIAGNOSIS_CODE DC from ecg_study WHERE PS_PROTOCOL_ID LIKE 'H6L-MC-LFAN'
    The above query returns comma separated value from the above query.
    I am using the query below to split the comma separated value but the below query is taking lot of time to return the data.
    SELECT
    select DC from (
    with t as ( select ES_DIAGNOSIS_CODE DC from ecg_study WHERE PS_PROTOCOL_ID LIKE 'H6L-MC-LFAN' )
    select REGEXP_SUBSTR (DC, '[^,]+', 1, level) DC from t
    connect by level <= length(regexp_replace(DC,'[^,]*'))+1 )
    Please suggest me is there any alternative way to do this comma separated value.
    Thanks
    Sudhir

    Nikolay Savvinov wrote:
    Hi BluShadow,
    I know that this function is fast with varchar2 strings from several years of using it. With CLOBs one may need something faster, but the OP didn't menion CLOBs.
    Best regards,
    NikolayJust because you perceive it to be fast doesn't mean it's faster than doing it in SQL alone.
    For starters you are context switching from the SQL engine to PL/SQL to call it.
    Then in your code you are doing this...
    select substr(v_str,v_last_break+1, decode(v_nxt_break,0,v_length, v_nxt_break-v_last_break-1)) into v_result from dual;which is context switching back from the PL/SQL engine to the SQL engine for each entry in the string.
    Why people do that I don't know... when PL/SQL alone could do it without a context switch e.g.
    v_result := substr(v_str,v_last_break+1, case when v_nxt_break = 0 then v_length else v_nxt_break-v_last_break-1 end);So, if you still think it's faster than pure SQL (which is what the OP is using), please go ahead and prove it to us.

  • HT2486 The selected file does not appear to be a valid comma separated values (csv) file or a valid tab delimited file. Choose a different file.

    The selected file does not appear to be a valid comma separated values (csv) file or a valid tab delimited file. Choose a different file.

    I guess your question is, "what's wrong with the file?"
    You're going to have to figure that out yourself, as we cannot see the file.
    Importing into Address book requires either a tab-delimited or a comma-delimited file. You can export out of most spreadsheets into a csv file. However, you need to make sure you clean up the file first.  If you have a field that has commas in the field, they will create new fields at the comma. So, some lines will have more fields than the others, causing issues like the error you saw.

  • How to seach for a particular text in comma separated values

    Hi,
    I have one table for eg. TB_Fruits.
    In that i have one column FruitsName(Varchar)
    In that column i am storing string in comma separated values.
    Select FruitsName from tb_fruits;
    Result: orange,banana,apple
    Now the issue is suppose if i try to insert any of these fruits name again then it should not allow me to insert.
    Suppose now if i try to insert ('grapes,banana')
    or
    ('apple,grapes')
    the orange,banana,apple can be in any position.
    How to check if any of these names already exist or not in the column fruitsname?
    I cannot use like or INstr function here. because the position is not fixed not even string.
    Appreciate any help.

    After doing search.
    Got to know <= 3 length in word is in stoplist.
    That's why the value ALL it was not searching in index.
    After modifying the index this problem is solved.
    CREATE INDEX
    Fruitsname_idx ON tb_fruits (FruitsName)
    indextype is ctxsys.context
    PARAMETERS('SYNC ( ON COMMIT)
    stoplist ctxsys.empty_stoplist');
    But now the issue is suppose i have value with space..
    i inserted one more row with value 'FRUITS YELLOW'
    So in the index it is storing two rows....one is for FRUITS and second is for YELLOW.
    select * from tb_fruits t where contains(t.FruitsName,'FRUITS')>0
    I will get record..but actually there should be no record.
    And it should allow me to insert. So i can insert the value FRUITS in more row.
    Any help on how to store the value with space in one row in index??

  • Comma Separated Values files ?!!

    Is there special classes for dealing with CSV (comma separated values) to use a text file just like a database ??
    thanks in advance

    sorry, it just sounds like a strange thing to do. Normally, you would not use CSV for persistent data storage with a High Level Language. In your design, if you wanted to refer to a particular record, you get into all sorts of problems. You could keep a note of where each record is, like what line number its on, but then you would need some way of modifying this note when you add records. Also, you would have to be sure that no-one is accessing the file outside of the program as then things will not be where the program expects them to be. You could refer to each record using some identifier, but then if you are going to start using all of this, then you may as well go the database route. If you are new to java, it will probably help you learn. I just don't envisage you ever having to use the type of design you are talking of in practice. The closest thing that you ever might use it for is if you had a plain text configuration or parameter file for a program.

  • Enable comma separated values (CSV) output

    I am trying to figure out how to (Enable comma separated values (CSV) output ) for a report. Do you have an example or info on how to do that?

    Can you provide an example on how you completed the setup? I am in the same boat but can't find an example to this subject

  • Converting xml data in to comma separated values in bpel

    Is there a way to covert generic xml data to comma separated value in BPEL? i have tried using createDelimitedString but no luck.
    Please guide me on this issue.
    Thanks!
    Shan
    Edited by: 876372 on Aug 3, 2011 6:58 AM

    Hi,
    Have a luk at the below link it has many examples:
    http://download.oracle.com/docs/cd/B31017_01/integrate.1013/b28994/nfb.htm

  • Comma separated Values have repeated values

    Find the Comma separated Values have repeated values
    say
    Str:= '123,abc,4566,4897996,46546546,ouiouiou,lhjlhlh,123,pojpoj,465465,123,poipoio,lahslka,'
    The above sting has 123 repeated 3 times i need to make a note of it and intimate to user
    can a Oracle Function does this?
    Thanks!

    This is one way of doing so, using Pure Oracle functions:
    with dat as
      select ',' || '123,abc,4566,4897996,46546546,ouiouiou,lhjlhlh,123,pojpoj,465465,123,poipoio,lahslka,' col
        from dual
    select col, length(translate(lower(replace(col, ',123,', '~')), '~abcdefghijklmnopqrstuvwxyz1234567890-=+_)(*&^%$#@!<>?":|}{,.', '~')) occurances
      from dat;
    COL                                                                                                                                                                         OCCURANCES         
    ,123,abc,4566,4897996,46546546,ouiouiou,lhjlhlh,123,pojpoj,465465,123,poipoio,lahslka,           3

  • Custom Document for Comma Separated Values in a JTextField

    Hi,
    I tried to create a custom structured Document implementation for comma separated values (on one line) in a JTextField:
    I want to have one LeafElement for each value (to store as an attribute the Object associated with this value). So, if I plug a DocumentListener to the JTextField, I can easily see which value(s) have been added/removed (see ElementChange).
    I used the PlainDocument implementation as a starting point and replaced the logic related to the '\n' character by the ',' (see #insertUpdate).
    Then I realized that the View must be customized too. So I created a View with a custom #paint method to draw each LeafElement on the same line.
    But, now, I try to fix the ElementChange returned by the #insertUpdate and #removeUpdate methods.
    Indeed, I played with a JTextArea with two lines "Bart\nisa" and plugged a debugging DocumentListener.
    And the event I get when I type 'L' before "isa" is really strange:
    - Two elements removed,
    - Two elements added.
    In the PlainDocument#insertUpdate, the code updates the 'offset' but I don't understand the logic behind.
    Could you explain me why I got this result?
    Could you give me an hint?
    Best Regards,
    El Barto.

    When you say the offset gets updated, I assume you're talking about this bit:
         int offset = chng.getOffset();
         int length = chng.getLength();
         if (offset > 0) {
           offset -= 1;
           length += 1;
         } The result is that, if a character is added at the very beginning or end of a line, the edit gets treated as a multi-line edit, which means the LeafElements on either side of the edit get removed and reconstructed. I discovered this behavior a few years ago, and I never have figured out what purpose it serves. I think you'll just have to try overriding the method to eliminate that behavior, and see what happens.

  • Comparing 2 comma separated value strings

    Hi
    I've the following requirement where i need to comapre 2 strings having comma separated values.
    declare
    v_Str1 varchar2(100) ;
    v_str2 varchar2(100);
    begin
    v_str1 := '123,234,456' ;
    v_str2 := '123,234';
    /*  *I need to write a logic to compare the above 2 strings
    Could you please give me  hint to achieve this*  */Thanks
    Edited by: smile on Mar 13, 2012 8:20 PM

    Try this
    declare
    v_Str1 varchar2(100) ;
    v_str2 varchar2(100);
    begin
    v_str1 := '123,234,456,4364' ;
    v_str2 := '123,234';
    For cur_rec in (
      select REGEXP_SUBSTR (v_str1, '[^,]+', 1, level) output
      from t
      connect by level <= regexp_count(v_str1,',')+1
      MINUS
      select REGEXP_SUBSTR (v_str2, '[^,]+', 1, level) output
      from t
      connect by level <= regexp_count(v_str2,',')+1) loop
      DBMS_OUTPUT.PUT_LINE(cur_rec.output);
    End loop;
    End;
    4364
    456
    PL/SQL procedure successfully completedAnother format
    declare
    v_Str1 varchar2(100) ;
    v_str2 varchar2(100);
    v_Str3 varchar2(100);
    begin
    v_Str1 := '600,100,500,200,300,400' ;
    v_Str2 :='100,200';
    For cur_rec in (
      select REGEXP_SUBSTR (v_str1, '[^,]+', 1, level) output
      from t
      connect by level <= regexp_count(v_str1,',')+1
      MINUS
      select REGEXP_SUBSTR (v_str2, '[^,]+', 1, level) output
      from t
      connect by level <= regexp_count(v_str2,',')+1) loop
      v_Str3:=v_Str3||','||cur_rec.output;
    End loop;
      v_Str3:=LTRIM(RTRIM(v_Str3,','),',');
      DBMS_OUTPUT.PUT_LINE(v_Str3);
    End;
    300,400,500,600
    PL/SQL procedure successfully completedEdited by: Lokanath Giri on १४ मार्च, २०१२ १:३३ अपराह्न

  • Query on column with comma separated values

    I have a proposed table with unnormalized data like the following:
    ID COLA COLB REFLIST
    21 xxx  zzz  24,25,78,412
    22 xxx  xxx  21
    24 yyy  xxx  912,22
    25 zzz  fff  433,555,22
    .. ...  ...  ...There are 200 million rows. There is maximum of about 10 IDs in the REFLIST, though typically two or three. How could I efficiently query this data on the REFLIST column? e.g. something like:
    SELECT id FROM mytable WHERE :myval in reflistLogically there is a many to many relationship between rows in this table. The REFLIST column contains pointers to ID values elsewhere in the table. The data could be normalized so that the relationship keys are in a separate table (in fact this is the current solution that we want to change).
    ID  REF
    21  24
    21  25
    21  78
    21  412
    22  21
    24  912
    ... ...The comma separated list seems instinctively like a bad idea, however there are various reasons for proposing it. The main reason is because the source for this data has it structured like the REFLIST example. It is an OLTP-like system rather than a data warehouse. The source code (and edit performance) would benefit greatly from not having to maintain the relationship table as the data changes.
    Going back to querying the REFLIST column, the problem seems to be building an approriate index for the data. The ideas proposed so far are:
    <li>Make a materialized view that presents the relationships as normalized (e.g. as in the example with ID, REF columns above), then index the plain column - the various methods of writing the view SQL have been widely posted.
    <li>Use a Oracle Text Index (not something I have ever had call to use before).
    Any other ideas? Its Oracle 10.2, though 11g could be possible.
    Thanks
    Jim

    Something like this ?
    This is test demo on my 11.2.0.1 Windows XP
    SQL> create table test (id number,reflist varchar2(30));
    Table created.
    SQL> insert into test values (21,'24,25,78,412');
    1 row created.
    SQL> insert into test values (22,'21');
    1 row created.
    SQL> insert into test values (24,'912,22');
    1 row created.
    SQL> insert into test values (25,'433,555,22');
    1 row created.
    SQL> select * from test
      2  where
      3  ',' || reflist || ',' like '%,22,%';
            ID REFLIST
            24 912,22
            25 433,555,22
    SQL>Source:http://stackoverflow.com/questions/7212282/is-it-possible-to-query-a-comma-separated-column-for-a-specific-value
    Regards
    Girish Sharma
    Edited by: Girish Sharma on Jul 12, 2012 2:31 PM

Maybe you are looking for

  • Problems with music player after upgrade to V20 (N...

    I upgraded my phone last week to the V20... And now when i go to transfer music through music manager it will not refresh the music library? Anyone help? When i press refresh it just freezes and i have to turn it off when turned back on i can then ac

  • Fail to add mailbox database copy

    Hello, When I am trying to add a mailbox database copy in DAG, I receive the following error: error The seeding operation failed. Error: An error occurred while performing the seed operation. Error: Failed to notify source server 'mbx1.domain.local'

  • How to convert photo shop docs to .pdf

    I accidently used photo shop to opened a .pdf file and now all of my .pdf file have to be imported to photo shop to open and I am not able to get all the pages.  How am I able to correct this problem and use Adobe Acrobat to open the .pdf file?

  • How to convert Mpeg 2 to usable format for imovie

    I have been trying for months, and am completely frustrated. I have a 2x2.8 Ghz Quad Core Tower running 10.6.8.  I have all three imovies installed - Imovie HD, imovie 7.1 and imovie 9. All have the most recent updates. I had trouble importing severa

  • Why does object show up through Heal/Clone

    I am working on a photo of Big Ben, taken on a recent trip. I have done some fairly extensive darkening/contrast to the sky to bring out the clouds, and the photo is almost perfect (for me). However, there is an object poking into the photo in the cl