How to store the values separated by commas

Hi all

I have a table named discount, with discount_id (number data type) as one of the columns.
The user gives an entry as the value separated by commas, (ex: '123,27890,3543')
I use built-in proc that separates the values separated by commas.
DECLARE
   l_input   VARCHAR2 (4000) := '123,27890,3543';
   l_count   BINARY_INTEGER;
   l_array   DBMS_UTILITY.lname_array;
BEGIN
   DBMS_UTILITY.comma_to_table (
      list     => REGEXP_REPLACE (l_input, '(^|,)', '\1x'),
      tablen   => l_count,
      tab      => l_array);
   DBMS_OUTPUT.put_line (l_count);   

   FOR i IN 1 .. l_count
   LOOP
      DBMS_OUTPUT.put_line (
            'Element '
         || TO_CHAR (i)
         || ' of array contains: '
         || SUBSTR (l_array (i), 2));
   END LOOP;
END;

Result:
3
Element 1 of array contains: 123
Element 2 of array contains: 27890
Element 3 of array contains: 3543
Result set is stored in a table.
I would like to do a select on the table of discounts
Select * discount where discount_id (123, 27890 3543).

I am looking for options,
I need to create a new physical table as
Create table new_table (identification number) and bulk insert in this table.
Select * discount where discount_id in (select distinct id of new_table).
or
Is there a better way?

THX
Rod.

Hello, SamFisher.
May be the recursive subquery factoring help you?

WITH test(f1, n) AS (select '12, 15, 235', 1 from dual
                     UNION all
                     select f1, n + 1 from test where n < regexp_count('12, 15, 235', ',') + 1)
SELECT regexp_substr(f1, '[^, ]+', 1, n) f
FROM test

Tags: Database

Similar Questions

  • How to get the values separated by commas of multiple records in table

    How to get the values separated by commas of multiple records in table

    for example

    name address age sex
    a 12 m e
    b hh 12 f
    BB c 13 h

    I need to get output as a, b, c from a query

    Use the query as below he works for me, change the names of tables and columns

    SELECT SUBSTR (SYS_CONNECT_BY_PATH (PROXY_EMAIL, ','), 2) csv FROM (SELECT PROXY_EMAIL, ROW_NUMBER () ON the rn (ORDER OF PROXY_EMAIL), COUNT (*) NTC (STARS_PROXY_ASSIGNMENT) WHERE EMPLID = #EMPLID) WHERE rn = cnt START WITH rn = 1 CONNECT BY rn = rn + 1 ADVANCE

  • How to pass the values separated by commas in SQL query

    Hi all

    I use Oracle APEX 4.2

    I've created a report of iterative with condition 1 ITEM IS NOT NULL.

    This is the SQL query

    SELECT MY. ACCT_ID,

    JAI DETAILS

    The ACCT MA, ACCT_hist EB

    WHERE MY. ACCT_IK = EB. ACCT_IK

    AND MY. ACCT_ID IN (: P3_IN_MRN);

    A P3_IN_MRN element is a text field. The thing is that it works if I give a value, but its does not work if I have several values with comma separated as 123,345,543.

    What could be the solution for multiple values in the SELECT query.

    Really appreciate your help.

    I made use of this on pretty much every project I've worked on:

    https://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:210612357425

    Hope that helps.

    Duncs

  • 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

  • How to store the value in labview

    I write a VI and need set a reference point before I have my operation.

    Is there a way to hold the values for all 8 channels I am able in a constant number at the push of a button?

    If I had this, I might just have the VI subtract these core values on and get my reference.

    Thank you!

    Generally, you would hold the reference value in a knot of registry or feedback shift.

    Here's a simple example (LV 8.0)

  • How to store the value in the database using UTF-8 Content-Type

    Hi all

    I created a web application that uses soap services.

    I want to store data in my data base oracle in Hindi language, so I configured my compiler Jdeveloper in UTF - 8 as well as my oracle database also supports utf - 8.

    but when I store hindies data through web service (Soap service), value was stored as? in my database.

    where as when I store data hindies without web service data is stored as unicode (& #23455 ;) who can be recover in hindi font I have my jsp pages.

    Here is my sample code:

    package com.example.service;

    import com.example.bean.LanguageBean;

    import com.example.conn.OracleDBConnection;

    import java.sql.Connection;

    import java.sql.PreparedStatement;

    import java.sql.ResultSet;

    import java.util.ArrayList;

    import java.util.List;

    Import javax.jws.WebService;

    Import javax.xml.ws.BindingType;

    Import javax.xml.ws.soap.MTOM;

    Import javax.xml.ws.soap.SOAPBinding;

    @WebService (serviceName = "ExampleService", endpointInterface = "com.example.service.ExampleServicePortType")

    @BindingType (SOAPBinding.SOAP12HTTP_BINDING)

    public class ExampleService {}

    Connection con = null;

    PreparedStatement pst;

    ResultSet RST;

    public ExampleService() {}

    Super();

    }

    @WebMethod

    public String insertValue (String eng, hindi string) {}

    String result = null;

    try {}

    con = OracleDBConnection.getConnection ();

    PST = con.prepareStatement ("insert into test1 values(?,?)" "") (English, hindi);

    pst.setString (eng, 1);

    pst.setString (2, hindi);

    int i = pst.executeUpdate ();

    result = i + "Notice inserted successfully;

    } catch (Exception ex) {}

    ex.printStackTrace ();

    } {Finally

    try {}

    OracleDBConnection odbc = new OracleDBConnection();

    odbc.closeConnection ();

    } catch (Exception ex) {}

    ex.printStackTrace ();

    }

    }

    return the result;

    }

    @WebMethod

    public list < LanguageBean > getAllRecords() {}

    < LanguageBean > the list result = new ArrayList < LanguageBean > ();

    LanguageBean lbs = null;

    try {}

    con = OracleDBConnection.getConnection ();

    PST = con.prepareStatement ("select English, hindi test1");

    RST = pst.executeQuery ();

    While (rst.next ()) {}

    lb = new LanguageBean();

    lb.setEnglish (rst.getString ("english"));

    lb.setHindi (rst.getString ("hindi"));

    result. Add (lb);

    }

    } catch (Exception ex) {}

    ex.printStackTrace ();

    } {Finally

    try {}

    OracleDBConnection odbc = new OracleDBConnection();

    odbc.closeConnection ();

    } catch (Exception ex) {}

    ex.printStackTrace ();

    }

    }

    return the result;

    }

    }

    Same thing happened when I send data from Oracle Application of MAF.

    Thanks and greetings

    Patrick Srivastava

    Thank you all, I found the solution to my problem. I put the CharacterSeto of my Oracle in UTF - 8 database.

  • How to store the values of variable level OBIEE presentation in DB

    Hi all!

    We have a command prompt of dashboard which is set up to store values in variables of presentation (period start and period end dates). Is there a way to store values selected from a database? for further processing?
    that is, I need to pass the variable level (report parameters) presentation to complex calculations to a PL/SQL function.
    Also my requirement might be solved if I can get access to the selected values of logical column in the tab 'Business Model and mapping' definition in the BI administrator.
    that is, I'll be able to define the logical column using VALUEOF (NQ_SESSION. < nom_var >)

    Kind regards
    Mr.Maverick

    Hello.

    1 do SQL PL/function (in the database) which has an input parameters, which number depends on number of guests and in it you'll insert these parameters into a table.

    2. your report in column expression answers call this function that will do insert, the code would be like:
    EVALUATE ("YOUR_FUNCTION (1%, 2%, 3%, 4%) (' as varchar (20), @{p_1}, @{p_2}, @{p_3}, @{p_4})

    3. Note that the function returns something and be careful on data types inside EVALUATE it.

    4. notes that, in the case where some messages are not selected (all or nothing) you recognize this case as:

    -case when LENGTH('@{pv_var}') > 0 then ' @{pv_var}' end else' all '.

    or like this:

    -case when LENGTH('@{pv_var}') is null then 'all choice"other" @{pv_var}' end; "

    Kind regards
    Goran
    http://108obiee.blogspot.com

  • Column value separated by commas to convert to another value separated by commas and happening as a component of output sys_refcursor

    Hello

    I have 3 tables with the following structure.

    create table a_os_lang_stls

    (ID NUMBER )

    SWB_NUMBER VARCHAR2 (30),

    Pc_NUMBER VARCHAR2 (30),

    PC_FLAG TANK (1),

    INSTALLATION_ord NUMBER ,

    SP_OR_LATER_VSN TANK (1),

    Platform VARCHAR2 (4000),

       OS VARCHAR2 (4000),

    LANG VARCHAR2 (4000),

    LOSS_OF_FUNC_REASON_TXT VARCHAR2 (4000),

    CREATION_DATE DATE ,

    MODIFIED_DATE DATE ,

    CREATED_BY VARCHAR2 (100 BYTE),

    MODIFIED_BY VARCHAR2 (100 BYTE)

    );



    Insert in a_os_lang_stls

    values (1 'SWB1' 'SWB0','P',1 of ','11118,14,16,234,124' '12,26,17,24,35''34,28,45,67,123,95',USER, NULL, NULL, NULL, SYSDATE);

    Insert in a_os_lang_stls

    values (2,'SWB1' 'SWB2','P',2 of ','111,20,14,16,124''11,26,18,24,35''35,27,42,67,123,95', SYSDATE, NULL, NULL, NULL, USER);

    insert into a_os_lang_stls

    values (3,'SWB1','SWB3','C', 1,'','11118,14,16,234,124','12,26,17,24,35',' 35,27,42,67,123,95', SYSDATE, NULL, NULL, NULL, USER);

    insert into a_os_lang_stls

    values (4,'SWB1','SWB4','C', 2,'','111,20,14,16,124','11,26,18,24,35'' 34,28,45,67,123,95, SYSDATE, NULL, NULL, NULL, USER)



    CREATE TABLE os_dtls

    (

      OSCODE                 VARCHAR2 (10 BYTE),

    ID NUMBER DEFAULT NULL,                                     

    AG_OSCODE VARCHAR2 (250 BYTE),

    );


    insert into os_dtls

    values ('HUX', 12, 'HP UNIX');

    insert into os_dtls

    values('SUX',26,'SOLARIS');

    insert into os_dtls

    values ('LUX', 17, 'LINUX');

    CREATE TABLE lang_dtls

    (

    LANGCD TANK (2 BYTE),

    LANGNAME VARCHAR2 (255 BYTE),

    ID NUMBER DEFAULT 1 NOT NULL                                                          

    );


    insert into lang_dtls

    values ('ENG', 'ENGLISH UK', 35);

    insert into lang_dtls

    values ('UEG', 'USA ENGLISH', 27);

    insert into lang_dtls

    values('FR','FRENCH',45);

    Information on the database:

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

    PL/SQL version 11.1.0.7.0 - Production

    Production base 11.1.0.7.0

    AMT for Linux: Version 11.1.0.7.0 - Production

    NLSRTL Version 11.1.0.7.0 - Production

    I have to write a procedure like this

    procedure os_lang_info (P_SB_NO IN varchar2, p_pcur sys_refcursor, p_ccur, sys_refcursor );

    The requirement is to get the details for a given swb_no where pc_flag is P or C pass like 2 different sys_refcursor. But the value of column of bones and lang I need to map to the os_dtls and lang_dtls tables to get the ag_oscode and langname respectively for the corresponding id then through sys_refcursor.

    So sys_refcursor structure will be

    Open the p_pcur for

    Select * from a_os_lang_stls

    where swb_number = p_sb_no

    and PC_FLAG = 'P' ;


    so the output will resemble the following

    1 , « SWB1 » , « SWB0 » , 'P' , 1 , 'S' , '11118,14,16,234,124' , «HP UNIX,SOLARIS,LINUX,... « , "UK ENGLISH,US ENGLISH,FRENCH,...» ', NULL, NULL, NULL, USER, SYSDATE

    I must get the id separated by commas of column bone and lang and map to the corresponding table to get the names separated by commas of the bones and langs and pass it as a component of sys_refcursor.

    Open the p_ccur for

    Select * from a_os_lang_stls

    where swb_number = p_sb_no

    and PC_FLAG = 'C';



    Could someone please help me how to convert the value separated by commas in a comma separated value new map to another table and pass it as part of the sys_refcursor.



    Thanks in advance.


    Kind regards

    SB2011



    Hello. Here are the queries for the two sys_refcursors.

    (1) FOR THE FLAG = 'P '.

    SELECT T1.ID,

    T1. SWB_NUMBER,

    T1. PC_NUMBER,

    T1. PC_FLAG,

    T1. INSTALLATION_ORD,

    T1. SP_OR_LATER_VSN,

    T1. PLATFORM,

    T1. OS_CODE,

    T2. LANG_CODE

    DE)

    SELECT T1.ID,

    SWB_NUMBER,

    PC_NUMBER,

    PC_FLAG,

    INSTALLATION_ORD,

    SP_OR_LATER_VSN,

    PLATFORM,

    RTRIM (XMLAGG (XMLELEMENT(A,AG_OSCODE,',')). Extract ('//Text ()'), ',') OS_CODE

    FROM (SELECT ID,

    SWB_NUMBER,

    PC_NUMBER,

    PC_FLAG,

    INSTALLATION_ORD,

    SP_OR_LATER_VSN,

    PLATFORM,

    (COLUMN_VALUE). GETNUMBERVAL() os_id

    Of a_os_lang_stls t, xmltable (os) t1) T1.

    OS_dtls T2

    WHERE T2.ID = T1. OS_ID

    GROUP OF T1.ID,

    SWB_NUMBER,

    PC_NUMBER,

    PC_FLAG,

    INSTALLATION_ORD,

    SP_OR_LATER_VSN,

    T1 PLATFORM),

    (SELECT T1.ID,

    SWB_NUMBER,

    PC_NUMBER,

    PC_FLAG,

    INSTALLATION_ORD,

    SP_OR_LATER_VSN,

    PLATFORM,

    RTRIM (XMLAGG (XMLELEMENT(A,LANGNAME,',')). Extract ('//Text ()'), ',') LANG_CODE

    FROM (SELECT ID,

    SWB_NUMBER,

    PC_NUMBER,

    PC_FLAG,

    INSTALLATION_ORD,

    SP_OR_LATER_VSN,

    PLATFORM,

    (COLUMN_VALUE). GETNUMBERVAL() lang_id

    Of a_os_lang_stls t, xmltable (lang) t1) T1.

    lang_dtls T2

    WHERE T2.ID = T1.lang_id

    GROUP OF T1.ID,

    SWB_NUMBER,

    PC_NUMBER,

    PC_FLAG,

    INSTALLATION_ORD,

    SP_OR_LATER_VSN,

    T2 PLATFORM)

    WHERE T1.ID = T2.ID

    AND T1. SWB_NUMBER = T2. SWB_NUMBER

    AND T1. PC_NUMBER = T2. PC_NUMBER

    AND T1. INSTALLATION_ORD = T2. INSTALLATION_ORD

    AND T1. PLATFORM = T2. PLATFORM

    AND T1. PC_FLAG = "P";

    (2) PC_FLAG FOR = 'C '.

    SELECT T1.ID,

    T1. SWB_NUMBER,

    T1. PC_NUMBER,

    T1. PC_FLAG,

    T1. INSTALLATION_ORD,

    T1. SP_OR_LATER_VSN,

    T1. PLATFORM,

    T1. OS_CODE,

    T2. LANG_CODE

    DE)

    SELECT T1.ID,

    SWB_NUMBER,

    PC_NUMBER,

    PC_FLAG,

    INSTALLATION_ORD,

    SP_OR_LATER_VSN,

    PLATFORM,

    RTRIM (XMLAGG (XMLELEMENT(A,AG_OSCODE,',')). Extract ('//Text ()'), ',') OS_CODE

    FROM (SELECT ID,

    SWB_NUMBER,

    PC_NUMBER,

    PC_FLAG,

    INSTALLATION_ORD,

    SP_OR_LATER_VSN,

    PLATFORM,

    (COLUMN_VALUE). GETNUMBERVAL() os_id

    Of a_os_lang_stls t, xmltable (os) t1) T1.

    OS_dtls T2

    WHERE T2.ID = T1. OS_ID

    GROUP OF T1.ID,

    SWB_NUMBER,

    PC_NUMBER,

    PC_FLAG,

    INSTALLATION_ORD,

    SP_OR_LATER_VSN,

    T1 PLATFORM),

    (SELECT T1.ID,

    SWB_NUMBER,

    PC_NUMBER,

    PC_FLAG,

    INSTALLATION_ORD,

    SP_OR_LATER_VSN,

    PLATFORM,

    RTRIM (XMLAGG (XMLELEMENT(A,LANGNAME,',')). Extract ('//Text ()'), ',') LANG_CODE

    FROM (SELECT ID,

    SWB_NUMBER,

    PC_NUMBER,

    PC_FLAG,

    INSTALLATION_ORD,

    SP_OR_LATER_VSN,

    PLATFORM,

    (COLUMN_VALUE). GETNUMBERVAL() lang_id

    Of a_os_lang_stls t, xmltable (lang) t1) T1.

    lang_dtls T2

    WHERE T2.ID = T1.lang_id

    GROUP OF T1.ID,

    SWB_NUMBER,

    PC_NUMBER,

    PC_FLAG,

    INSTALLATION_ORD,

    SP_OR_LATER_VSN,

    T2 PLATFORM)

    WHERE T1.ID = T2.ID

    AND T1. SWB_NUMBER = T2. SWB_NUMBER

    AND T1. PC_NUMBER = T2. PC_NUMBER

    AND T1. INSTALLATION_ORD = T2. INSTALLATION_ORD

    AND T1. PLATFORM = T2. PLATFORM

    AND T1. PC_FLAG = 'C ';

  • Left join of the two tables and multiple values into a single value separated by commas

    Hello

    I have following tables with their structures and their data as below.

    CREATE TABLE 'BETODI '. "" BETINFO ".

    (

    VARCHAR2 (8 BYTE) "CURRENTPRESS."

    ENABLE 'TYPEIDCONTAINER' VARCHAR2 (30 BYTE) NOT NULL

    )

    INSERT INTO Betinfo (Currentpress, typeidcontainer) VALUES ('A24G', 'PMC');

    INSERT INTO Betinfo (Currentpress, typeidcontainer) VALUES ('A24D', 'Pensky-MARTENS');

    INSERT INTO Betinfo (Currentpress, typeidcontainer) VALUES ("A25D", "CMP");

    INSERT INTO Betinfo (Currentpress, typeidcontainer) VALUES ('A25G', 'PMC');

    INSERT INTO Betinfo (Currentpress, typeidcontainer) VALUES ('A26D', 'PMC');

    INSERT INTO Betinfo (Currentpress, typeidcontainer) VALUES ('A26G', 'PMC');

    INSERT INTO Betinfo (Currentpress, typeidcontainer) VALUES ("A32G", "V-BFC3");

    INSERT INTO Betinfo (Currentpress, typeidcontainer) VALUES ('A32D', "V-BFC2");

    CREATE TABLE 'BETODI '. "" BETMASTER ".

    (

    ACTIVATE THE "CUREPRESS" TANK (5 BYTES) NOT NULL,

    ACTIVATE THE "TYPE" VARCHAR2 (5 BYTE) NOT NULL,

    NUMBER (5.0) "LASTPCIRIM".

    )

    INSERT INTO BetMaster (Curepress, type, lastpcirim) VALUES ('A24', '45 M 8', 15);

    INSERT INTO BetMaster (Curepress, type, lastpcirim) VALUES ('A25', 42 16', 15);

    INSERT INTO BetMaster (Curepress, type, lastpcirim) VALUES ("A26", 16' 45, 15);

    INSERT INTO BetMaster (Curepress, type, lastpcirim) VALUES ("A27", '45 M 34', 16);

    INSERT INTO BetMaster (Curepress, type, lastpcirim) VALUES ('A28', '45 M 34', 16);

    INSERT INTO BetMaster (Curepress, type, lastpcirim) VALUES ('A29', '45 M 34', 16);

    INSERT INTO BetMaster (Curepress, type, lastpcirim) VALUES ('A30', '45MCH', 15);

    INSERT INTO BetMaster (Curepress, type, lastpcirim) VALUES ("A31", "45MCH", 16);

    INSERT INTO BetMaster (Curepress, type, lastpcirim) VALUES ('A32', '45MCH', 16);

    INSERT INTO BetMaster (Curepress, type, lastpcirim) VALUES ('A33', '45MCH', 16);

    INSERT INTO BetMaster (Curepress, type, lastpcirim) VALUES ("A34", "45MCH", 16);

    These two tables have left join as

    BETMASTER. CUREPRESS = substr (BETINFO. CURRENTPRESS, 1, 3)

    now I want to have the data in the two tables with fields Curepress, Lastpcirim, typeidcontainer.

    Also something like

    Make a group of typeidcontainer if this value is greater than 1 by press separated the values of semicolon (;)

    So, for example above, we should be given as

    A24 PMC 15; PENSKY-MARTENS

    A25 15 PMC

    A26 15 PMC

    A27 16 (NULL)

    A28 16 (NULL)

    A30 15 (NULL)

    A31 16 (NULL)

    A32 16 BFC2-V; V BFC3

    A33 16 (NULL)

    A34 16 (NULL)

    How could do?

    My current request is as

    Select distinct Curepress, lastpcirim, typeidcontainer

    BETMASTER STD left join INF BETINFO

    on the trim (STD. CUREPRESS) = substr (trim (INF. CURRENTPRESS), 1, 3)

    but I am unable to get the values separated by commas.

    Any help would be appreciated.

    Thank you

    Mahesh.

    Hi, Mahesh,

    If you want to only 1 row of output for each distinct combination of currentpress and lastpcirim?  This sounds like a job for GROUP BY.

    And you want the row to contain a list of all different typidcontainers-delimited?  This sounds like a job for the aggregate LISTAGG function.

    WITH joined_data AS

    (

    SELECT DISTINCT

    MST.curepress, mst.lastpcirim, inf.typeidcontainer

    OF betmaster STD

    LEFT JOIN betinfo ON TRIM (mst.curepress) inf = SUBSTR (TRIM (inf.currentpress)

    1

    3

    )

    )

    SELECT curepress, lastpcirim

    LISTAGG (typeidcontainer, ',')

    THE Group (ORDER BY typeidcontainer) AS container_list

    OF joined_data

    Curepress GROUP, lastpcirim

    ;

    Unfortunately, you can't say LISTAGG (DISTINCT ...), so you should always get the separate containers how you already are.  (Note that the subquery is just what you posted).

    Thanks for posting the CREATE TABLE and INSERT statements; It is very useful.  Don't forget to tell what version of Oracle you are using.  LISTAGG was new in Oracle 11.2.

    Why not add CHECK constraints (and perhaps triggers) to your tables, so that curepress and currentpress are not stored with the head or trailing spaces?  Then you wouldn't need to use the PAD in queries like this, and your code would be simpler and more effective.

  • How to search for a particular text values separated by commas

    Hello

    I have a table for example. TB_Fruits.
    In that I have a FruitsName (Varchar) column
    In this column I store the string of values separated by commas.
    Select FruitsName in the tb_fruits;
    Result: orange, banana, Apple

    Now the question is suppose that if I try inserting one of these fruits once again name, then it must not allow me to insert.

    Suppose that now if I try to insert ('grapes, banana')
    or
    (Apple, grape")

    the orange, banana, Apple may be in any position.

    How to check if one of these names exist already or not in the fruitsname column?
    I can't use INstr function here as or. because the position is not fixed chain even not.

    Appreciate any help.

    Hmm, OK, the BASIC_LEXER in the documentation is specified is useful to "spaces separate languages". So not really a good suggestion from my side ;-)

    Okay, so a few different choices, you can play with:

    SQL> create table tb_fruits (
      2     fruitsname  varchar2(60)
      3  )
      4  /
    
    Table created.
    
    SQL> begin
      2     insert into tb_fruits values ('BANANA,APPLE');
      3     insert into tb_fruits values ('YELLOW BANANA,ORANGE');
      4     insert into tb_fruits values ('GREEN APPLE,YELLOW ORANGE');
      5     insert into tb_fruits values ('APPLE,GREEN BANANA');
      6     commit;
      7  end;
      8  /
    
    PL/SQL procedure successfully completed.
    

    Option 1:

    Make a outdated AS operator. It just won't be fast because it's more likely will be full table scan (or scan restricted index full).

    SQL> select fruitsname
      2    from tb_fruits
      3   where ','||fruitsname||',' like '%,'||'APPLE'||',%'
      4  /
    
    FRUITSNAME
    ------------------------------------------------------------
    BANANA,APPLE
    APPLE,GREEN BANANA
    
    SQL> select fruitsname
      2    from tb_fruits
      3   where ','||fruitsname||',' like '%,'||'BANANA'||',%'
      4  /
    
    FRUITSNAME
    ------------------------------------------------------------
    BANANA,APPLE
    
    SQL> select fruitsname
      2    from tb_fruits
      3   where ','||fruitsname||',' like '%,'||'YELLOW BANANA'||',%'
      4  /
    
    FRUITSNAME
    ------------------------------------------------------------
    YELLOW BANANA,ORANGE
    

    Option 2:

    Transform your data and replace the spaces with underscores. Which may or may not be a possibility for you. If your other data contains no underscores, you might fool your user interface using a view that replaces underscores with spaces when you select and a trigger before insert that replaces spaces with underscores to insert or update. Then, you can use the TEXT index.

    SQL> create table tb_fruits2 as
      2  select replace(fruitsname,' ','_') fruitsname
      3    from tb_fruits
      4  /
    
    Table created.
    
    SQL> begin
      2     ctx_ddl.create_preference('mylex', 'BASIC_LEXER');
      3     ctx_ddl.set_attribute('mylex', 'printjoins', '_-');
      4  end;
      5  /
    
    PL/SQL procedure successfully completed.
    
    SQL> create index fruitsname_idx on tb_fruits2 (fruitsname)
      2  indextype is ctxsys.ctxcat
      3  parameters (
      4  'stoplist ctxsys.empty_stoplist
      5  LEXER mylex'
      6  )
      7  /
    
    Index created.
    
    SQL> select fruitsname
      2    from tb_fruits2
      3   where catsearch(fruitsname,replace('YELLOW BANANA',' ','_'),null) > 0
      4  /
    
    FRUITSNAME
    ------------------------------------------------------------
    YELLOW_BANANA,ORANGE
    

    (I used CTXCAT rather then CONTEXT indexes to keep simple search syntax, avoid SYNCHRONIZATION problems and others. You can use CONTEXT or CTXCAT as desired.)

    Option 3:

    Transform your data in XML format instead of values separated by commas. Then create a XMLIndex.

    SQL> create table tb_fruits3 as
      2  select xmltype(''||replace(fruitsname,',','')||'') fruitsname
      3    from tb_fruits
      4  /
    
    Table created.
    
    SQL> create index fruitsname_xmlidx on tb_fruits3 (fruitsname)
      2  indextype is xdb.xmlindex
      3  /
    
    Index created.
    
    SQL> select fruitsname
      2    from tb_fruits3
      3   where xmlexists('$f/l[w="YELLOW BANANA"]' passing fruitsname as "f")
      4  /
    
    FRUITSNAME
    --------------------------------------------------------------------------------
    YELLOW BANANAORANGE
    

    (I used just 'l' for 'list of the words' and 'w' for 'word').

    Option 4:

    Create your own [url http://docs.oracle.com/cd/E11882_01/text.112/e24436/cdatadic.htm#i1008347] USER_LEXER instead of a variant of BASIC_LEXER. This would require allows you to create your own stored procedures for the index to be used, in which case you have complete control over what you set in the form of a token.

    That's the different options I can think of right now ;-)

  • How to acquire and store the values of DAQmx analog voltage (I do not want the graphic, but strings and values in a chart)?

    Hello

    How acquire and store the values of voltage DAQmx?

    I tried several code example, but they can't get the chart. I don't want to chart. I want to measure exactly the analog voltage values and record these values - as an excel chart, that contains the selected channels and voltage values.

    What the example code that I can use?

    My hardware is NI PCI-6251.

    Thank you very much.


  • How to store the query string value in the scope of the session in webcenter spaces?

    Hello

    I want to store the query string value (which is given from URL) in the sessionScope variable. According to the value of sessionScope beacause I went some components inside my taskflow. Can someone help me how to store this value in the scope of the session. I use webcenter spaces for my application development.

    Thank you

    Ashok.

    Please see the article below

    How to pass a parameter of argument the query URL to a parameter input workflow? (Doc ID 1545808.1).

  • Display data in the form of values separated by commas - need help

    Hi all

    I have some data formatted in the way below. The ID of the drug are the primary keys of the table and the first 9 digits in the drug ID are the same. They can be separated based on the last two digits.

    Type of drug drug ID
    00603107554 respiratory
    00603107556 cough and cold
    Antitussive-00603107558


    I want that data to be formatted as
    Type of drug drug ID
    006031075 respiratory, cough and colds, Antitussive

    I want to cut the last two characters, and format data. And the types must be displayed in the form of values separated by commas. Can someone help me?

    Thanks in advance

    Rambeau
    WITH t AS (SELECT '00603107554' Drug_ID, 'Respiratory' Drug_Type FROM DUAL
               UNION
               SELECT '00603107556', 'Cough and Cold' FROM DUAL
               UNION
               SELECT '00603107558', 'Antitussive' FROM DUAL)
        SELECT Drug_id, SUBSTR (SYS_CONNECT_BY_PATH (Drug_Type, ','), 2) Drug_Types
          FROM (SELECT SUBSTR (drug_id, 1, LENGTH (drug_id) - 2) drug_id,
                       Drug_Type,
                       ROW_NUMBER ()
                       OVER (PARTITION BY SUBSTR (drug_id, 1, LENGTH (drug_id) - 2)
                             ORDER BY Drug_Type)
                          rn
                  FROM t)
         WHERE CONNECT_BY_ISLEAF = 1
    START WITH rn = 1
    CONNECT BY PRIOR rn = rn - 1 AND PRIOR drug_id = drug_id
    
    DRUG_ID     DRUG_TYPES
    006031075     Antitussive,Cough and Cold,Respiratory
    

    just a note, I wonder if blushadow could consider adding techniques agg string to its very useful faq section because it seems a good
    request.

    Published by: pollywog on April 14, 2011 06:42

    Published by: pollywog on April 14, 2011 06:43

  • Display values in the columns separated by commas.

    Hello world

    Table 1

    col1 col2
    ID1Name1
    ID2name2
    ID3Name3

    Table 2

    col1 col2
    RQ11
    RQ23, 2
    rQ32, 3

    Result table

    col1 col2
    RQ1Name1
    RQ2Name2, Name3
    rQ3name2, Name3

    Based on table 1 and table 2 to create a view to produce a result array.

    Ideas experts!

    Little things...

    First of all, given in TABLE1. Col1 stores values as ID1, ID2... But the associated column in TABLE2. Col2 stores the value in the form 1, 2... Is this correct? Then, the data into TABLE2. Col2 is not the right way to store your data. TABLE2 is not standardized. And it is a very bad way to design a database.

    Says you can try this solution here I Unpivot firstly the list of values in TABLE2. Col2 in lines and then enclose it with TABLE1 and finally make an aggregation of chain. It is a solution prior 11g. If you are on 11g and above, you can use functions like UNPIVOT and LISTAGG wisely.

    with table1

    as

    (

    Select "id1" col1, col2 "Name1" Union double all the

    Select "id2" col1, col2 "Name2" Union double all the

    Select 'id3' col1, col2 "Name3" of the double

    ),

    Table2

    as

    (

    Select "rq1" col1, col2 '1' of any Union double

    Select "rq2" col1, col2 '3.2' of any union double

    Select "rq3" col1, col2 '2.3 ' double '.

    )

    table2_expand

    as

    (

    Select col1

    , regexp_substr (col2, ' [^,] +', 1, level) col2

    level lvl

    from table2 t2

    connect

    by level<= length(col2)="" -="" length(replace(col2,="" ','))="" +="">

    and col1 = col1 prior

    and prior sys_guid() is not null

    )

    Select col1, ltrim (sys_connect_by_path (col2, ',') ',') col2

    BeO

    Select t2.col1, t1.col2, row_number() over NWR (partition by order of t2.col1 of t2.lvl)

    FROM table1 t1

    Join the t2 table2_expand

    on t1.col1 = 'id ' | T2.col2

    )

    where connect_by_isleaf = 1

    beginning

    with rno = 1

    connect

    by rno = prior rno + 1

    and col1 = col1 prior

  • Store the value less than the current week and the year.

    Hi all

    I have a table called BACK, which structure is like this
    ITEM_NUMBER   YEAR_WEEK   MS
    ...........   .........   ..
    1N58          2012-WK02   01/15/2012
    1N58          2011-WK02   01/15/2011
    current my procedure I store the value in my new table that is less than the current week. But I want to retain the value less than the current week and the current year. Please, help me to get how I can do this.
    PROCEDURE BACKLOG_PROC_LT_CW IS
      BEGIN
     DELETE BACKLOG_LT_CW;
     COMMIT;
          INSERT INTO BACKLOG_LT_CW
            SELECT 
                  DC_UTIL.GEN_YEAR_WEEK(MS) YEAR_WEEK,
                  ITEM_NUMBER,
                  MSD
    
                  FROM BACKLOG
              where to_char(MS, 'IW')<to_char(sysdate, 'IW');
    
      END BACKLOG_PROC_LT_CW;
    Currently, with the above code is to store the value in my table of BACKLOG_LT_CW but if you see the data in the table from the BACK you will find YEAR_WEEk 2012-WK02 falls next year, but again it is store in my table because IW took only. Please help me get the soln

    Thanks in advance

    Concerning

    Are you looking for this?

    ...
    where to_char(MS, 'YYYYIW')
    

Maybe you are looking for

  • Firefox don't keep me connected when I ask him to

    whenever I come Firefox I have to connect to my email & it remembers me when I him ask for how can - I address this issue

  • upgrade memory 2540p

    How many modules memory are there on the 2540p? Of after Crucial, there are two. According to my system, I have 4 GB installed (3.80 GB usable).But when I take the cover on the back, I can only find a single SODIM 2 GB module and on You Tube, they sh

  • unlocked iPhone, but ask for the activation of the SIM

    I bought an iPhone 6 from the UK as a factory unlocked. I have never had any problem with any carrier other whatsoever. Recently, I restored (also tried in DFU mode) iOS phone and on the restoration, he asked for activation and said that my SIM card

  • Windows XP Microsoft Auto update

    How can I remove red x by security updates

  • Print al problema

    The problem that I have are cuando voy a print any document, the bar of PROPIEDADES esta inactiva y no puedo senalar o so what I need. Is he the Patrick desinstalado y the nuevo pero instaled nor is ha arreglado el problema. If alguien me you can ind