creation of selection using comma-separated values list

Hi all

I have the column in the database containing values separated by commas
for ex: Pune, Mumbai, Bangalore...

I want to create the selection list using higher values.
for ex: Pune
Mumbai
Bangalore


Please help me on this issue.

Thanks in advance,
Jitendra

Hello

Try the following

select regexp_substr(YOUR_FIELD_NAME,'[^,]+', 1, level) display_value,
       regexp_substr(YOUR_FIELD_NAME,'[^,]+', 1, level) return_value
  from YOUR_TABLE
  connect by regexp_substr(YOUR_FIELD_NAME, '[^,]+', 1, level) is not null

Concerning

Graham

Published by: gpc on February 1, 2012 11:27

Tags: Database

Similar Questions

  • 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
    
  • Using 'text field contains comma-separated values' on a parameter of %

    Hello

    I use a parameter that has more than one value to be entered, separated by commas. I checked the box 'text field contains values separated by commas' for the parameter and set the sql code by using the operator 'in' so that the column will look in the multiple input values (e.g. family name in (: surname_par)). However, as passing multiple values parameter must also be able to manage %'s. As the sql uses the 'in' operator, BI Publisher brings back an error because % is supposed to bring all family names and not people with a last name of %. Is there a way to get around this?

    Thank you

    If you try to pass multiple values separated by commas and in addition also takes the query to return the data when the user types just in '%', then you could write something like this in your query:

    Select * from table_name
    where ((1 = DECODE (: surname_par, '%', 1, 0)) OR family name in (: surname_par))

    I hope this helps. Please award points if helpful/correct.

  • 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 Separated Values in Bind Variable

    Hello

    I'm on Oracle9i Enterprise Edition Release 9.2.0.6.0 - Production.I use in query
    select * from employees where first_name in ('Ajay','Ajay5')
    It gives me two rows as it should. Now, I want to pass these values as a bind variable.
    select * from employees where first_name in :1
    Now when I run the query and make its contribution as a ('Ajay', 'Ajay5'). It gives me no line.

    Is their any way to do this. Let me know if you have any questions

    Thank you
    AJ

    Check out this link: the Blog of Tom Kyte: varying in lists...

  • How do I get the number by using the sql values list

    DECLARE

    v_rec_cnt number: = 0;

    Type v_table is table of the varchar2 (9);

    card_tab v_table: = v_table)

    '372131483',

    '372131566',

    '372131618',

    '372131720',

    '372131801',

    '372131885',

    '372131976',

    '372132058'... records 110000lacks)

    and org_colo_cam_id = 6827;

    Start

    Because me in card_tab. First... card_tab. Last

    loop

    SELECT count (1) in the v_rec_cnt OF dtc_tab_random_no dorn

    WHERE org_colo_cam_id = 6827 and

    NVL(attribute01,'@null@') = 'OFFICE '.

    and dorn_card_no = card_tab (i);

    v_rec_cnt: = v_rec_cnt + 1;

    end loop;

    dbms_output.put_line (' County :'|| v_rec_cnt);

    END;

    I need to get the values in list of bove records I write the script run I got this error can u please help for this

    I got IN the operator, but 1000 is limit in thank you operator for help

    Error on line 1

    ORA-06550: line 4, column 11:

    PLS-00801: internal error [22510]

    ORA-06550: line 4, column 11:

    PL/SQL: Ignored Element

    ORA-06550: line 117342, column 10:

    PLS-00320: the declaration of the type of the expression is incomplete or incorrect

    through utl_file.get_line the id to select queries count (1) inner loop passes the id I had the County thanks

  • Order with comma separated values?

    I have the following table

    create table ord as
    (select col1 '4,7,10'
    Union
    "4,7,8'."
    Union
    '5,6,11'
    Union
    '4,7,10'
    Union
    '4,7,6'
    Union
    '4,7,7'
    the double)

    I mean select * from DSB order by col1 and the by should look at every number in the column ordering him to string vs...
    Currently 4,7,10 comes first (as it is a string comparison), but I want to come 4,7,6 first.

    It could by urgent for you, but it is not, we have our own work to do.

    In any case...

    It will focus on any number of numbers in the list up to 10 digits long each...

    SQL> ed
    Wrote file afiedt.buf
    
      1  with ord as
      2  (select '4,7,10' col1 from dual union
      3   select '4,7,8' from dual union
      4   select '5,6,11' from dual union
      5   select '4,7,10' from dual union
      6   select '4,7,99,4' from dual union
      7   select '4,7,6' from dual union
      8   select '4,7,7' from dual)
      9  -- End of test data
     10  select col1
     11  from ord
     12* order by regexp_replace(regexp_replace(col1,'(^|,)([^,]+)','\1000000000\2'),'(^|,)[^,]*([0-9]{10})(,|$)','\1\2\3')
    SQL> /
    
    COL1
    --------
    4,7,6
    4,7,7
    4,7,8
    4,7,10
    4,7,99,4
    5,6,11
    
    6 rows selected.
    
    SQL>
    

    If you need to more digits cos you're numbers are bigger, so you need to change the regular expression to pad with more than 0 (inbetween the \2 \1) and cut to the required length or replace the {noformat} {10} {noformat} with the number of digits required.

  • ODI extract data from HFM using hierarchies / members whose list of filters

    Hi all

    is it possible to use lists of members or hierarchies from account to account and filter data HFM LKM to SQL entity?

    In the example:

    ACCOUNT_FILTER = AccList (where AccList is a list)

    or

    ACCOUNT_FILTER = AccX. * (where the CAC is a parent account and we want that all his children)

    ODI, Version 10.1.3.6.5

    Thank you

    I don't think it's possible, you must provide a list of the accounts comma separated values

  • JavaScript to set radio button choices using the drop-down list box value.

    I use Adobe Acrobat Pro DC version 2015.016.20039 on a MacBook Pro OS X El Capitan version 10.11.6.

    I have a set of named CitBox radio box choices. I'm defining what choice is selected from out of a drop-down list named AppCitizenship box.  Both of them have six choices with values of 1, 2, etc. (I thought having the same values would make easier the translation from one to the other). Thanks in advance.

    If you used the same values, then it is pretty easy. Just use this code as the validation script custom field drop-down list:

    this.getField("CitBox").value = event.value;

  • Slide to pause until that value is selected from a drop down list?

    Hi there everyone.

    I try to create a cover page of sorts for a simulation of system where the user is asked to enter his name and choose where they work in for a combo box (using the drop-down list box widget)

    I have the name entry part work and the drop-down list box is displayed, but I'm having some problems with it.

    First of all, as soon as a value is selected in the box is jumps to the next slide. I would have rather navigation controlled by a button that the user can make sure that they have chosen the correct value before continuing. Is there a way to do this?

    Hello

    This is the craziest question, but think I found the reason: Although the widget looks a lot smaller in edit mode, when opening it (preview or published) it falls above the button. When I have it away, seems to work. Can you confirm?

    Lilybiri

  • How can I use two drop-down lists for a time value?

    I want to enter the length of time someone did something in hours and minutes using two drop-down lists, then enter it as a time value only (├a) in Mysql.

    I used the dropdown database lists and a few different variations of what follows without success (seconds is a hidden field with a value of "00"):

    GetSQLValueString (strftime ("% H: % i: %s", strtotime ($_POST ["sleeptimemin"].))) " «. $_POST ['sleeptimehr']. » «. (_POST ["seconds"])) $, 'date').

    This comes back to 00:00:16, regardless of what is selected in the drop-down list.

    Any help would be appreciated.

    MySQL stores time in human-understandable format, using the 24-hour clock.

    GetSQLValueString($_POST['sleeptimehr'] . ':' . $_POST['sleeptimemin'] . ':00', "date"),
    
  • How to get the value of the selection of the text box list

    Hello

    I have a selection list that I want to retrieve the value of the selection of the text box list.

    How can I do this?


    Kind regards
    Santini.

    Hi Sarah,.

    Yo can use Java script for this...

    Dynamically the value will enter in the text box.

    Use the script below.

    
    

    See you soon,.
    Shan

  • The specified display list is invalid or points of view have been selected using a different pattern

    Hello Experts,

    I get an error when I perform the aggregation using the aggregation view which was working fine before. We have ASO cube.

    'The list of the specified view is invalid or points of view have been selected using a different scheme'

    No major changes has been (as change the ownership/megaupload type etc).

    No addition of level in one of the dimension.

    Only members are added at the same level

    Please let me know what would cause to become invalid.

    Thank you

    Raja Mohamed

    RajaMohamed wrote:

    The change is only the addition of members at the same level.

    Only way I can see what is possible is if the dimension change your attributes, and where you had already all members, associated with an attribute, you have now a few not associate members.

    Take a good copy of the outline (or restore from backup) and run the MaxL following on the old and the new cubes:

    query database app.db list aso_level_info;
    

    That should show you where the differences are.

  • How to set a repeating subform based on a value selected in a drop down list?

    Please forgive me if this is somewhere, but I spent a few hours searching and have not led to what.

    I have a drop-down list that allows the user to select the number of teams in you listing (1-5). Then I have a subform with all the necessary information for each team. I wish that the subform to repeat automatically based on the number selected in the drop-down list, because I need this information for each of the two teams by registering.

    Thank you!

    In the case of exit of the drop-down list, in formcalc, put something like:

    teams of var = $.rawValue

    var counter = 1

    While (counter< teams)="">

    Subform2.instanceManager.addInstance)

    Counter = counter + 1

    endwhile

    This assumes you have already 1 version of the subform. If you are a beginner with no condition (meter while doing<=>

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

Maybe you are looking for

  • Designjet Z2100: Buy a used Z2100. This who should I look for?

    I am considering buying a Z2100 used to, essentially, a few cents of a liquidator for recovery.  The printer has remained for months with no cartridge but some print heads (I know are probably trash). I have an another Z2100 that I can borrow the ink

  • How to get the VI

    What program can get the VI (pictured)

  • prompt you to save the image in an avi file

    Hello I try with vision acquisition software and I managed to acquire my webcam image and store it in an avi file, but the problem is when I run vi again it will crush the avi file. Is is possible to create a new avi file every time I stop and run th

  • E55-210 lens case/sleeve

    Someone at - it a reccomendation on a case/sleeve and a view to buy it for the 55-210 E goal? Need something light, but protection to keep it in a backpack while hiking. Thank you!

  • start the administrator

    Hello I'm not a Labview programmer but I'm the owner of a system controlled by Labview tool. The program is launched with a right click Administrator mode. The OS is windows 7. I would like to know if the program can be started directly, administrato