How to split a  comma seperated varray element ..

Hi ,
If I have varray with elements in the below fashion.
first element -- 'var1=v1'
Second element -- 'var2=v2'
third element --' var3=v3'
fourth element -- 'var4=v4'
fifth element -- 'var5=v5'
Is there a way I can split them to get as the following
var1
v1
var2
v2
var3
v3
var4
v4
var5
v5
Basically each varray element is seperated by a equal to sign '='.
Thanks & Regards

this query may help you to get your output.
with t as (
select 1 rn,'var1=v1'  ccc  from dual
union all
select 2,'var2=v2' from dual
union all
select 3,'var3=v3' from dual
union all
select 4,'var4=v4' from dual
union all
select 5,'var5=v5' from dual)
select * from (
select rn,substr(ccc,1,instr(ccc,'=')-1) from t
union all
select rn,substr(ccc,instr(ccc,'=')+1) from t) order by 1

Similar Messages

  • Is there any inbuilt function to split a comma seperated text

    Dear Friends,
    Is there any inbuilt function to split a comma seperated text for inserting the values thus split in to a table.
    Text Ex: Mango, Orange, Pinapple, Jack Fruit
    Output: Mango
    Orange
    Pineapple
    Jack Fruit
    Thanking you,
    With regards,
    Franklin

    Using DBMS_UTILITY.COMMA_TO_TABLE:--
    DECLARE
    l_tab dbms_utility.uncl_array;
    l_tablen number;
    BEGIN
    dbms_utility.comma_to_table('A,B,C', l_tablen, l_tab);
    dbms_output.put_line('TABLE LENGTH : '|| l_tablen);
    dbms_output.put_line('TABLE COUNT : '|| l_tab.COUNT);
    for i in 1..l_tablen
    loop
    dbms_output.put_line(l_tab(i));
    end loop;
    END;
    source --google.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

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

  • Count the number of elements in comma seperated list of values

    Hello Friends,
    I have a string with comma seperated list of values say
    String v = 34343,erere,ererere,sdfsdfsdfs,4454,5454,dsfsdfsfsd,fsdfsdfsdfs,dfdsfsdfsdfs,sdsfdsf,ererdsdsd45454,fsdfsdfs
    Want to count how many elements are existing in this string .
    Thanks/Kumar

    Hi, Kumar,
    REGEXP_COUNT, which Hoek used, is handy, but it only works in Oracle 11. Which version of Oracle are you using?
    In any version of Oracle, you can count the commas by seeing how much the string shrinks when you remove them.
    LENGTH (str) + 1 - LENGTH (REPLACE (str, ',')) Can str have multiple commas in a row? What if there's nothing between consecutive commas, or nothing by whitespace? Can str begin or end with a comma? Can str consist of nothing but commas? Depending on your answers, you may have to change things. You might want
    REGEXP_COUNT ( str
                 , '[^,]+'
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using.
    See the forum FAQ {message:id=9360002}

  • How to split comma delimited string?

    Hi,
    I have a parameter called Id in my SP which will be of nvarchar data type and i'm going to get the multiple ids at a time seperated by commas in that parameter from the application. Now my requirement is to update a table with these comma seperated ids in seperate rows.
    For example, if i have 2 parameters called Id1 and Id2. Id1 will contain only one value and will be of int data type and Id2 will be of nvarchar data type as i can get multiple ids delimited by a comma from the application. Suppose Id1 = 1 and Id2 = '1,2,3,4'. Then I have to update id2 in the tables seperately like wherever Id1 is '1' i need to update Id2 column for 4 rows with the value 1, 2, 3, 4 respectively in different rows.
    Could you please tell me how can i do this in T-SQL? How can i split the data of parameter Id2 in 4 different rows?
    Please let me know if you did not understand the question.
    Thanks,
    Deepti

     deeptideshpande wrote:
    Hi,
    I got a similar function which is like this:
    CREATE FUNCTION dbo.fnSplit(
    @sInputList VARCHAR(8000) -- List of delimited items
    , @sDelimiter VARCHAR(8000) = ',' -- delimiter that separates items
    ) RETURNS @List TABLE (item VARCHAR(8000))
    BEGIN
    DECLARE @sItem VARCHAR(8000)
    WHILE CHARINDEX(@sDelimiter,@sInputList,0) <> 0
    BEGIN
    SELECT
    @sItem=RTRIM(LTRIM(SUBSTRING(@sInputList,1,CHARINDEX(@sDelimiter,@sInputList,0)-1))),
    @sInputList=RTRIM(LTRIM(SUBSTRING(@sInputList,CHARINDEX(@sDelimiter,@sInputList,0)+LEN(@sDelimiter),LEN(@sInputList))))
    IF LEN(@sItem) > 0
    INSERT INTO @List SELECT @sItem
    END
    IF LEN(@sInputList) > 0
    INSERT INTO @List SELECT @sInputList -- Put the last item in
    RETURN
    END
    GO
    Now when i use this in my select statement, i get data in a tabular structure as shown below:
    select
    from dbo.fnSplit('1,22,333,444,,5555,666',
    Results
    Item
    1
    22
    333
    444
    5555
    666
    Now my requirement is to insert this value in a table which has 2 columns ID1 and ID2.
    At any point of time ID1 will be an int value(only one id in that parameter) and ID2 can have multiple ids delimited by comma. With the help of above split function i can split values of ID2 into 6 different ids but i need to insert the table
    in the following way:
    ID1     ID2
    1        1
    1        22
    1        333
    1        444
    1        5555
    1        666
    How can i insert the data in the above mentioned fashion.
    Thanks,
    Deepti
    Like this:
    Code Snippet
    select 1 as id,* from dbo.fnSplit('1,22,333,444,,5555,666', ',')
    Great!!!! Wonderfull!!!... Thanks a lot.

  • How to seperate the data with comma seperator ??

    Hi,
      How to seperate the data with comma seperator ??
    E.g i havea row like
    Userid,number of days,Total Records
    user1,10,100000
    So,i will get 10,10000 in the same field and i need to seperate 10 and 10000 so what is the abap function for that
    Praff

    like this ...
    SPLIT field AT ',' INTO
       userid
       days
       records.
    is this what you need?
    Mike

  • How to make comma seperated file

    hi
    I have a select statement that looks like below. I want to make comma seperated file for the selected columns. How to write it?
    SELECT MM.DAL_NUMBER,
    '19-NOV-2009' as WSS_CE,
    CPN_INT,
    TRADE_DATE,
    MX_DATE "LAST_DATE",
    CUSTOMER_SPECIF CUST_GID,
    NAME_SHORT CUST_NAME_SHORT
    from my_table;
    if you could provide me with exact query.
    Thanks

    Slightly more generic approach...
    As sys user:
    CREATE OR REPLACE DIRECTORY TEST_DIR AS '\tmp\myfiles'
    GRANT READ, WRITE ON DIRECTORY TEST_DIR TO myuser
    /As myuser:
    CREATE OR REPLACE PROCEDURE run_query(p_sql IN VARCHAR2
                                         ,p_dir IN VARCHAR2
                                         ,p_header_file IN VARCHAR2
                                         ,p_data_file IN VARCHAR2 := NULL) IS
      v_finaltxt  VARCHAR2(4000);
      v_v_val     VARCHAR2(4000);
      v_n_val     NUMBER;
      v_d_val     DATE;
      v_ret       NUMBER;
      c           NUMBER;
      d           NUMBER;
      col_cnt     INTEGER;
      f           BOOLEAN;
      rec_tab     DBMS_SQL.DESC_TAB;
      col_num     NUMBER;
      v_fh        UTL_FILE.FILE_TYPE;
      v_samefile  BOOLEAN := (NVL(p_data_file,p_header_file) = p_header_file);
    BEGIN
      c := DBMS_SQL.OPEN_CURSOR;
      DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE);
      d := DBMS_SQL.EXECUTE(c);
      DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
      FOR j in 1..col_cnt
      LOOP
        CASE rec_tab(j).col_type
          WHEN 1 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
          WHEN 2 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val);
          WHEN 12 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val);
        ELSE
          DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
        END CASE;
      END LOOP;
      -- This part outputs the HEADER
      v_fh := UTL_FILE.FOPEN(upper(p_dir),p_header_file,'w',32767);
      FOR j in 1..col_cnt
      LOOP
        v_finaltxt := ltrim(v_finaltxt||','||lower(rec_tab(j).col_name),',');
      END LOOP;
      --  DBMS_OUTPUT.PUT_LINE(v_finaltxt);
      UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
      IF NOT v_samefile THEN
        UTL_FILE.FCLOSE(v_fh);
      END IF;
      -- This part outputs the DATA
      IF NOT v_samefile THEN
        v_fh := UTL_FILE.FOPEN(upper(p_dir),p_data_file,'w',32767);
      END IF;
      LOOP
        v_ret := DBMS_SQL.FETCH_ROWS(c);
        EXIT WHEN v_ret = 0;
        v_finaltxt := NULL;
        FOR j in 1..col_cnt
        LOOP
          CASE rec_tab(j).col_type
            WHEN 1 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
                        v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
            WHEN 2 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_n_val);
                        v_finaltxt := ltrim(v_finaltxt||','||v_n_val,',');
            WHEN 12 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_d_val);
                        v_finaltxt := ltrim(v_finaltxt||','||to_char(v_d_val,'DD/MM/YYYY HH24:MI:SS'),',');
          ELSE
            v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
          END CASE;
        END LOOP;
      --  DBMS_OUTPUT.PUT_LINE(v_finaltxt);
        UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
      END LOOP;
      UTL_FILE.FCLOSE(v_fh);
      DBMS_SQL.CLOSE_CURSOR(c);
    END;This allows for the header row and the data to be written to seperate files if required.
    e.g.
    SQL> exec run_query('select * from emp','TEST_DIR','output.txt');
    PL/SQL procedure successfully completed.Output.txt file contains:
    empno,ename,job,mgr,hiredate,sal,comm,deptno
    7369,"SMITH","CLERK",7902,17/12/1980 00:00:00,800,,20
    7499,"ALLEN","SALESMAN",7698,20/02/1981 00:00:00,1600,300,30
    7521,"WARD","SALESMAN",7698,22/02/1981 00:00:00,1250,500,30
    7566,"JONES","MANAGER",7839,02/04/1981 00:00:00,2975,,20
    7654,"MARTIN","SALESMAN",7698,28/09/1981 00:00:00,1250,1400,30
    7698,"BLAKE","MANAGER",7839,01/05/1981 00:00:00,2850,,30
    7782,"CLARK","MANAGER",7839,09/06/1981 00:00:00,2450,,10
    7788,"SCOTT","ANALYST",7566,19/04/1987 00:00:00,3000,,20
    7839,"KING","PRESIDENT",,17/11/1981 00:00:00,5000,,10
    7844,"TURNER","SALESMAN",7698,08/09/1981 00:00:00,1500,0,30
    7876,"ADAMS","CLERK",7788,23/05/1987 00:00:00,1100,,20
    7900,"JAMES","CLERK",7698,03/12/1981 00:00:00,950,,30
    7902,"FORD","ANALYST",7566,03/12/1981 00:00:00,3000,,20
    7934,"MILLER","CLERK",7782,23/01/1982 00:00:00,1300,,10The procedure allows for the header and data to go to seperate files if required. Just specifying the "header" filename will put the header and data in the one file.
    Adapt to output different datatypes and styles are required.

  • How to convert string containing comma seperated values to an array

    my requirement is i have to first convert an comma seperated string to an array
    after that i have to pass the array values to a for loop
    eg:i have a string str=(456,457,487,465,478)
    These values i have to put in an array.
    i then i have to pass the array values to a for loop

    We understand your ¿homeworks? We are helping you, but it seems like you want us to do it.
    Try it yourself with some of the instructions.
    Anyway if there aren´t homeworks, use dinamyc sql:
    declare
    varray := '(45,65,12,4)';
    begin
    execute immediate 'update table set ss=''uu'' where id in ' || varray;
    end;

  • How to pass values with comma to comma seperated param in sp

    hi all,
     i have one sp which has param name as cordinatorname varchar(max)
    in where condition of my sp i passed as
    coordinator=(coordinatorname in (select ltrim(rtrim(value)) from dbo.fnSPLIT(@coordinatorname,',')))
    but now my promblm is for @coordinatorname i have values as 'coorcinator1', 'coordinato2,inc'
    so when my ssrs report taking these values as multiselect, comma seperated coordinator2,inc also has comma already
    how to get this solved. please help me..
    lucky

    In the SSRS report, on the parameters tab of the query definition, set the parameter value to
    =join(Parameters!<your param name>.Value,",")
    In your query, you can then reference the value like so:
    where yourColumn in (@<your param name>)
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Splitting comma seperated column data into multiple rows

    Hi Gurus,
    Please help me for solving below scenario. I have multiple value in single column with comma seperated values and my requirement is load that data into multiple rows.
    Below is the example:
    Source Data:
    Product         Size                                 Stock
    ABC              X,XL,XXL,M,L,S                 1,2,3,4,5,6
    Target Data:
    Product         Size                                 Stock
    ABC              X                                     1
    ABC              XL                                   2
    ABC              XXL                                 3
    ABC              M                                    4
    ABC              L                                      5
    ABC             S                                        6
    Which transformation we need to use for getting this output?
    Thanks in advance !

    Hello,
    Do you need to do this tranformation through OWB mapping only? And can you please tell what type of source you are using? Is it a flat file or a table?
    Thanks

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

  • Comma seperated file uploading

    Hi ,
    i want to upload comma seperated file into sap.
    iam using 'GUI_UPLOAD' fm.
    problem is flat file currency field it is also contains comma.
    i can't change file type comma to tab.
    How can i upload currency fields with comma.
    Regards,
    Suresh.

    You can upload your file into a string table. Now split it:
    split uploadtab at ',' into table items.
    if you have
    a,b,c,11,d,e,f
    your tables items contains 7 elements now.
    if you have
    a,b,c,11,22,d,e,f
    your table contains 8 elements now. In that case you now that you have splitted a number with a comma and need to do some actions, e.g. merge elements 4 and 5 together to get 11,22 again and shift the 6th to 5th, the 7th to 5th and the 8th to 7th element.
    After that you number is again in item 4.
    An easier way is to enforce you customer to put values into apostrophes or quotes. If this is not possible, you have to check if an unwanted split was taken in place and act as shown above.
    But: this will work only if one item with a comma in between. If oyu have more components you can not evaulate where the unwanted split is in effect.

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

  • How to read a tab seperated data from a text file using utl_file

    Hi,
    How to read a tab seperated data from a text file using utl_file...
    I know if we use UTL_FILE.get_line we can read the whole line...but i need to read the tab separated value separately.....
    Thanks in advance...
    Naveen

    Naveen Nishad wrote:
    How to read a tab seperated data from a text file using utl_file...
    I know if we use UTL_FILE.get_line we can read the whole line...but i need to read the tab separated value separately.....If it's a text file then UTL_FILE will only allow you to read it a line at a time. It is then up to you to split that string up (search for split string on this forum for methods) into it's individual components.
    If the text file contains a standard structure on each line, i.e. it is a fixed delimited structure, then you could use external tables to read the data instead.

  • I have a huge file which is in GB and I want to split the video into clip and export each clip individually. Can you please help me how to split and export the videos to computer? It will be of great help!!

    I have a huge file which is in GB and I want to split the video into clip and export each clip individually. Can you please help me how to split and export the videos to computer? It will be of great help!!

    video
    What version of Premiere Elements do you have and on what computer operating system is it running?
    Please review the following workflow.
    ATR Premiere Elements Troubleshooting: PE11: Project Assets Organization for Scene and Highlight Grabs from Collection o…
    But please also determine if your project goal is supported by
    a. format of your source
    and
    b. computer resources
    More later based on details that you will post.
    ATR

Maybe you are looking for

  • IPad Air too much time to open a link from Mail

    SInce the last update to iOS 8.02 my iPad Air takes too much time to open a web link from the Mail App, Safari open itself with a long delay. furthermore The attachments into email are often not readable, have to reload the message to be able to open

  • How do I close a book and go back to the library?

    How do I close a book and go back to the Iibrary?

  • On Demand - sound & picture freezing

    For about 10 days now we have had an issue with our On Demand service.  Mostly, the just sound goes but also the whole thing freezes for a couple of seconds, before going again for another couple of seconds.  Rinse & repeat. We have been on the phone

  • IPad 2 keeps freezing, soft reset has no effect

    Hi there, My iPad 2 has frozen 3 times in the past week and will only respond once I restore it.  This has just started happening and it's almost every day now. I've tried all the suggestions, all aspects of the screen freezes including the red slide

  • QuickTime Broadcaster, from MPEG-2 to H.264 stream

    Can QT Broadcaster connect to a MPEG-2-stream, convert it to H.264 MPEG-4 and broadcast the new stream on the fly?