How to query the comma seperated values stored in Database

Hi,
I have a strange scenario, I am storing the specific data as a comma seperated value in the database. I want to query the DB with the comma seperated value as a Bind variable against the comma seperated value stored in DB.
For eg : The data stored in DB has
Row1 - > 1,2,3,4,5,6,7,8
Row2 - > 4,5,6,7,8,9,10
When I pas the Bind variable as '4,8' I should get Row1 and Row2 .
Quick help his highly appreciated.. Thanks in Advance

Oh, and if you actually wanted the data returned rather than just the row primary keys....
SQL> ed
Wrote file afiedt.buf
  1  with t as (select 1 as rw, '1,2,3,4,5,6,7,8' as txt from dual union all
  2             select 2, '4,5,6,7,8,9,10' from dual union all
  3             select 3, '1,6,7,9' from dual)
  4  -- end of test data
  5      ,r as (select '4,8' as req from dual)
  6  -- end of required data
  7      ,split_t as (select rw, regexp_substr(txt, '[^,]+', 1, rn) as val
  8                   from t, (select rownum rn from dual connect by rownum <= (select max(length(regexp_replace(t.txt, '[^,]'))+1) from t))
  9                   where regexp_substr(txt, '[^,]+', 1, rn) is not null
10                  )
11      ,split_r as (select regexp_substr(req, '[^,]+', 1, rownum) as val
12                   from r
13                   connect by rownum <= length(regexp_replace(req, '[^,]'))+1
14                  )
15  --
16  select distinct t.rw, t.txt
17  from   split_t st join split_r sr on (st.val = sr.val)
18                    join t on (t.rw = st.rw)
19* order by 1
SQL> /
        RW TXT
         1 1,2,3,4,5,6,7,8
         2 4,5,6,7,8,9,10
SQL>

Similar Messages

  • Converting the comma seperator value  format

    i am getting the content of a table in a internal table with comma separator value format, dynamically by using dfies table i am getting the header of the table, and displaying it in the output, now my query is that the content of the data which i am getting in a itab having only one field of type string
    data : begin of itab occurs 0,
              data1 type string,
             end of itab.
    some where they were concatenating the content of the data and storing it inthe itab, now i want the content of the itab should be displayed corresponding to there header in the output

    Hi Santosh,
    You can remove the commas from the record by using the REPLACE command as below -
    LOOP AT itab.
      DO.
        REPLACE ',' WITH '' INTO itab-data1.
        IF sy-subrc NE 0.
          EXIT.
        ENDIF.
      ENDDO.
    ENDLOOP.
    Reward points if found useful...!
    Cheers
    Abhishek

  • How to display the comma separeated values in a row in the form of coulmns?

    Hi,
    I have a table as shown below.
    Table name: Projs
    Project_Id Associates_List
    proj1 2,3,4,5
    proj2 2,5,1
    We are looking at moving this data into a normalized format as shown below.
    Project_Id Associates_List
    proj1 2
    proj1 3
    proj1 4
    proj1 5
    proj2 2
    proj2 5
    proj2 1
    How can we achieve this?
    If anybody knows, please provide the soultion.

    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select 'proj1' as proj_id, '2,3,4,5' as asoc_list from dual union all
      2             select 'proj2', '2,5,1' from dual)
      3  -- END OF TEST DATA
      4  select proj_id, asoc
      5  from (
      6        select proj_id
      7              ,regexp_substr(asoc_list, '[^,]+', 1, rn) as asoc
      8        from   t
      9              ,(select rownum rn
    10                from dual
    11                connect by rownum <= (select max(length(regexp_replace(asoc_list,'[^,]')))+1
    12                                      from t
    13                                     )
    14               ) x
    15       )
    16  where asoc is not null
    17* order by 1, 2
    SQL> /
    PROJ_ ASOC
    proj1 2
    proj1 3
    proj1 4
    proj1 5
    proj2 1
    proj2 2
    proj2 5
    7 rows selected.
    SQL>Edited by: BluShadow on Oct 29, 2009 3:09 PM
    reworded a.s.s. so that profanity checker doesn't complain.

  • How to save the own fields value in a Database

    Hi all
    We create some customers fields with eewb fields for Service Order, but the value we enter in it, are not saved into the database table CRMD_ORDERADM_H.
    Where and what we have to do to commit the values in the database?
    We are working with CRM2007 WEB UI.
    Best Regards
    Edited by: Luis Felice on Nov 18, 2008 9:14 PM

    Did you check that your new fields have been created in table CRMD_ORDERADM_H?
    If yes, then check the structure of context node BTAdminH in TX GENIL_MODEL_BROWSER.
    If the fields popup in both, then everything with the EEWB should have worked fine.
    The EEWB creates an include structure for the table. This structure is also include in all API (like the CRM_ORDER_MAINTAIN). Additionally it creates function modules that are called by the API and handle the additional fields. Thus you do not have to do any additional commit or coding.
    In case everything is in place and it does not work, you should probably open an OSS. Otherwise let the wizard in the EEWB create the extension again.
    cheers Carsten

  • How to store Comma Seperated Value in a File with Jsp

    Hai friends,
    I need to get all the filed values like Empname,salary ,location..........
    and at the end of jsp page i have to put a browse button when i choose a file using theis browse button the total content in the form shoud store in that file as comma seperated values.

    1. Create JSP
    2. When you click the button call the event that saves the data in CSV format
    Your question is so broad, I don't have exact answer for you.
    What have you done so far?
    The man with blues.

  • Inserting comma seperated values

    I created a stored procedure that creates an order_id. Using this id, the products and their pricetag are inserted. Hereafter the garnishes are inserted for each product.
    Creating an order id and inserting the products and their pricetag are working. The problem is at the inserting of garnishes. 
    The data is received by parameters, and I have also created a user defined type: where garnishId holds the comma seperated ids.
    CREATE TYPE [dbo].[ppg] AS TABLE(
    [ProductId] [int] NULL,
    [PriceId] [int] NULL,
    [garnishId] [VARCHAR](MAX) NULL
    this is the stored procedure:
    ALTER PROCEDURE [dbo].[sp_create_order]
    (@userId uniqueidentifier, @productPriceGarnishes dbo.ppg READONLY, @comment varchar(250))
    AS
    BEGIN
    DECLARE @orderId int
    DECLARE @orderDetailId int
    INSERT INTO orders (user_id, confirmed,comment) values(@userId,0,@comment);
    --Select last inserted PK
    SELECT @orderId=SCOPE_IDENTITY()
    -- insert products and price tag using @orderId
    INSERT INTO order_detail (order_id, product_id,price_id)
    SELECT @orderId, p.ProductId,
    p.PriceId
    FROM @productPriceGarnishes p
    SELECT @orderDetailId=SCOPE_IDENTITY()
    -- insert garnishes using the orderDetailId
    INSERT INTO order_detail_garnish (order_detail_id,garnish_id)
    SELECT @orderDetailId, (SELECT * FROM SplitDelimiterString(p.garnishId))
    FROM @productPriceGarnishes p
    END
    RETURN @orderId
    I found a function that splits the string by a delimiter in this website:
    http://www.codeproject.com/Tips/586395/Split-comma-separated-IDs-to-ge
    Where you can retrieve the ids by this query:
    (SELECT * FROM SplitDelimiterString(p.garnishId)
    The problem is that I don't know how to add these ids with their corresponding orderDetailId, after each product is added.

    Unfortunately it appears you assume too much.  Presumably the reason you chose to define @productPriceGarnishes as a table is to support the creation of multiple rows. And you use these rows to insert into the order_detail table which has an identity
    column as the primary key (again, presumably).  So the question then becomes how do you get the identity values for ALL of the inserted rows?  You can't do that with SCOPE_IDENTITY - your code currently is designed with the assumption that there
    is only one row to be inserted.  To work around that limitation you need to use the output clause (examples can be found by searching). 
    Next comes another problem.  How do you know which identity value is assigned to which row of your table variable during the insert?  You need some sort of natural key to associate the inserted rows with the rows in the table variable.  Do
    you have one?  Before you think you do, you need to think about what restrictions are placed on the content of the table variable (if any).  Is it possible to have multiple rows with the same values for ProductId and PriceId?  Do not assume
    - you need to be certain that this is or is not a possibility.
    Assuming that the rows are unique (which simplifies things greatly), you associate the inserted order_detail rows to the table variable via something like:
    select ... from @ins_detail as ins inner join @productPriceGarnishes as ppg
    on ins.ProductId = ppg.ProductId and ins.PriceId = ppg.PriceId
    Note that @ins_detail is a table variable that you would declare and populate via the output clause. It will contain the identity values for each row that you inserted.  With that, you can then generate the rows that you need to insert into the garnish
    table by applying the results of your splitter function.  Which is a step that I'll skip for now since you have much reading and work to do. 
    Now some last comments.  I am suspicious of a column named PriceId.  That is not a good sign - price is an attribute of something and not the basis of a relationship between tables.  The use of identity columns (especially as primary keys)
    can be a problem - and this is one good example.  Based on what I've just written and its assumptions, the natural key for order_detail is (order_id, product_id, price_id) - why do you need an identity column?  Again, searching will find past
    discussions about identity columns and their usage.

  • Have a column which is having comma seperated values.. and i am trying to s

    Have a column which is having comma seperated values.. and i am trying to seperate it.
    I am trying to create a stored procedure ..Version 11g xe. .and apex version 4..
    Here is the part of code..I cant make a procedure. .cause my statement consist with clause..
    create or replace procedure ins_adv_invoice
    (mmagazine_no number,madvtno number,missueno number,msection varchar2,mpagenumber varchar2,msalesman_code varchar2)
    is
    cursor cx is with testa as
    (select pagenumber name from advertiser)
    select regexp_substr(pagenumber, '[^,]+', 1, rownum) result
    from advertiser
    connect by level <= length(regexp_replace(pagenumber, '[^,]+')) + 1
    where advt_no = madvtno;
    begin
    for xxx in cx
    loop
    insert into adv_invoice (magazine_no,advtno,adissue,section,page_number,salesman_code)
    values (mmagazine_no,madvtno,missueno,msection,xxx.result,msalesman_code);
    end loop;
    end;
    But when i run this .. it doesnt create procedure. .I get he following error..
    LINE/COL ERROR
    5/14 PL/SQL: SQL Statement ignored
    9/69 PL/SQL: ORA-00933: SQL command not properly ended
    SQL>
    Still not able to figure it out..Can any one help..
    Thanks

    Change the query to swap the last two lines:
    cursor cx is with testa as
    (select pagenumber name from advertiser)
    select regexp_substr(pagenumber, '[^,]+', 1, rownum) result
    from advertiser
    where advt_no = madvtno
    connect by level <= length(regexp_replace(pagenumber, '[^,]+')) + 1;
    ...

  • Cut comma seperated value

    Can you pls help me on this
    table: emp_master
    Ename     Bonus(%)
    abc     15,5,20,10,40,10
    xyz     10,10,20,60
    table emp_sal
    Ename     Var
    abc     1000
    xyz     2000
    output result :
    Ename     Var
    abc     150(15 % X 1000)(15 is the first value from the comma seperated list in emp_master table)
    abc     50  ( 5 % X 1000) (5 is the second value from the comma seperated list in emp_master table)
    abc     200 (20 % X 1000)
    abc     100
    abc     400
    abc     100
    xyz     200
    xyz     200
    xyz     400
    xyz     1200Thanks in advance
    Edited by: user12093849 on Feb 3, 2010 12:34 AM

    Assuming you're on at least database version 10G:
    SQL> -- generating sample data:
    SQL> with emp_master as ( select 'abc' ename, '15,5,20,10,40,10' bonus from dual union all
      2                       select 'xyz', '10,10,20,60' from dual
      3                     )
      4  ,    emp_sal as ( select 'abc' ename, 1000 var from dual union all
      5                    select 'xyz', 2000 from dual
      6                  )
      7  --
      8  -- actual query:
      9  --
    10  select m.ename
    11  ,      m.bonus
    12  ,      s.var*m.bonus
    13  from  ( select a.ename
    14          ,      level lvl
    15          ,      regexp_substr (bonus, '[^,]+', 1, level)/100 bonus
    16          from   emp_master a
    17          connect by level <= length(regexp_replace(bonus,'[^,]*'))+1
    18          group by ename, bonus, level
    19         ) m
    20  ,      emp_sal s
    21  where  s.ename=m.ename      
    22  order by m.ename, m.lvl
    23  /
    ENA      BONUS S.VAR*M.BONUS
    abc        ,15           150
    abc        ,05            50
    abc         ,2           200
    abc         ,1           100
    abc         ,4           400
    abc         ,1           100
    xyz         ,1           200
    xyz         ,1           200
    xyz         ,2           400
    xyz         ,6          1200
    10 rows selected.

  • How to count " How many times the ' commit work ' Statement is executed.

    Hi all sap Champions,
    One of the client requirement, That is
    How to count " How many times the ' commit work ' Statement is executed.
    It's urgent.
    Please can anybody help me for this.
    Thanks
    Basu

    hi,
    when report try like this.
    declare a variable as
    data: counter type i value 0.
    COMMIT.
    counter = counter + 1.
    write:/10 counter 'NO. OF TIMES COMMIT WORKED'.

  • How to get the table of value field? and can we expand the technical limits

    Dear
    I have created value field in COPA with KEA6. And now, I need the table which the value fields are saved. Yet, I have tried a lot to find it and get failure? Can any guy help me? Please tell me how to get the table of a value field.
    And another question is that, can we extend the technical limits for the number of value field for ECC6.0?
    We have a note for R.4.x Please see below:
    OSS note 160892
    You can display the length of a data record using Transaction KEA0 ('Maintain Operating Concern'). After you have navigated to the 'Characteristics Screen' or to the 'Value field Screen' choose menu path 'Extras -> Technical Limits'.
    The maximum displayed here under 'Length in bytes on the DB' is the maximum length permitted by the Dictionary. The reserve required for the release upgrade must be subtracted from this value.
    To increase the allowed number of the value fields, increase the value that is assigned to field ikcge-bas_max_cnt (FORM init_ikcge_ke USING fm_subrc, approx. line 165) in Include FKCGNF20. It specifies the number of the possible value fields. The corresponding part of the source code is attached to the note as a correction.
    David Sun
    Regards!

    how to extend the limit of value numbers? please see the original question.

  • How to get the current month value for a customer exit variable?

    How to get the current month value for a customer exit variable? 
    And also if we have an InfoObject with date value (including date, month, year), then how to derive the month value from this date type of Char.?
    Thanks!

    Hi Kevin,
    Check here........
    Re: Customer Exist for "From Current Date To Month End"
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/25d98cf6-0d01-0010-0e9b-edcd4597335a
    Cal month
    Regards,
    Vijay.

  • How to get the previoulsy selected value in a combobox

    How to get the previoulsy selected value in a combobox. i WANT the current and the previously selected value of the combobox.

    Just add to combobox ItemListener. When item is changing in itemStateChanged arrives 2 events. ItemEvent.DESELECTED and ItemEvent.SELECTED with corresponding item's values. Just write something like this:
            comboBox.addItemListener(new ItemListener() {
                Object prevValue;
                public void itemStateChanged(ItemEvent e) {
                    if (e.getStateChange() == ItemEvent.SELECTED) {
                        //do what you need with prevValue here
                    } else {
                        prevValue = e.getItem();
            });

  • How to change the Credential domain Value in XML gateway?

    How to change the Credential domain Value in XML gateway?
    configured the XML Gateway trading partner . It is generating the header as given below. but need to change the Credential domain to DUNS.
    <Header>
    <From>
    <Credential domain="olgridap1.lan">
      <Identity>53369415-cxml</Identity>
    </Credential>
    </From>
    Desired XML header
    <Header>
    <From>
    <Credential domain="DUNS">
      <Identity>53369415-cxml</Identity>
    </Credential>
    </From>

    You might want to check WLP 10.3 & deployment plan & log4j.xml for a similar topic.

  • How to get the latest procured value of a spare updated in material master

    How to get the latest procured value of a spare updated in material master

    J S S PRASAD
    See table MBEW via transaction SE16.
    However, you may need to look at the last PO created for that material.
    PeteA

  • How to call the form bean value on jsp withthe help of jstl tag

    hi
    all friends
    i am working in struts & i use jstl tag in jsp. i have one problem rise is how to call the form bean value in jsp page by using jstl tag.
    i now how to retrive the value through jsp:logic
    eg. <logic:empty name="userListForm" property="users">
    NO USER FOUND
    </logic:empty>
    see * userListForm mean formbaen name.
    * users means collection object.
    so how can i write above e.g in jstl

    You use the jstl core:if or core:choose combined with the EL:
    <c:if test="${empty users.userListForm}">
    NO USERS FOUND
    </c:if>I suggest you lookup the jsp expression language (EL) using google, it's very powerful.

Maybe you are looking for

  • How to set the focus to the tabbed pane title?

    Dear Friends, I'm using tabbed pane (JTabbedPane) in my application. I have 2 tabbed panes and each contain some text fields and buttons. In first tabbed, I have 2 text fields, OK and Cancel buttons. I have to set the focus to the title of the tabbed

  • Error when trying to open group policy editor

    When I try to open the Local Group Policy Editor I get error message: "Found duplicate definition of element string with name 'AppxRuntimeBlockFileElavationExplanation'. File c:\Windows\PolicyDefinitions\en-US\AppXRuntime.adml, line43, column 15" I'm

  • Photoshop elements 12 and elements premier

    Will there be any difficulties downloading a hard copy of photoshop elements 12 and premier elements, when I have a copy of photoshop elements 6 installed.

  • Explain the Function module 'RHPP_COMMON_QUALI_READ'

    Please explain me ,how the functional module 'RHPP_COMMON_QUALI_READ' works.Also mention the input parameters and output that is expected.

  • HFM to pass data into Essbase

    Hi One of my clients requirment is to pass the data from HFM into Essbase after doing teh journal entries. Is EIS the only way or is there a better way of synchronizing HFM and Essbase together. Also, if EIS is included with teh license deal with Ess