Set of string into array or a table....

Hi Experts,
I am using Oracle 10G, where I need to accomplish a task...
I am getting a set of string of the sort
"|session_id~q_id~q_key~rt_id~rt_key~request_type~field_id|session_id~q_id~q_key~rt_id~rt_key~request_type~field_id| ....."
Here, as you can see every set which has 7 values is delimited by a "| (pipe)" and every value is delimited by a "~" ...
I need to insert all these into a generic table and before doing that I need to split it into individual values where every set which has 7 values will get into 7 columns in a row...
Can anyone help me out with a proper logic as to how do i go about accomplishing the same...???

Hi,
You have to use regular expression to tokenize string in fragments.
This is sample for determining CRLF in a string:
-- Tokenize rows
FOR token IN ( SELECT REGEXP_REPLACE(REGEXP_SUBSTR(XMLCDATA('custom_string') || Chr(10), '(.*' || Chr(10) || ')', 1, LEVEL ), Chr(10), '') t
FROM dual
CONNECT BY REGEXP_INSTR('custom_string'||Chr(10), '(.*'||Chr(10)||')',1, LEVEL ) > 0) LOOP
token.t --> single fragment
END LOOP;
Bear in mind that this forum is for Data Modeler product related issues, feedback etc. So before posting question search for appropriate forum. It's quite possible that you won't get answer while in wrong forum.
Regards
Edited by: Dimitar Slavov on Apr 15, 2011 2:11 AM

Similar Messages

  • How can i store values from my String into Array

    Hi guys
    i wants to store all the values from my string into an array,,,, after converting them into intergers,,,, how i can do this becs i have a peice of code which just give me a value of a character at time,,,,charat(2)...BUT i want to the values from String to store in an Array
    here is my peice of code which i m using for 1 char at time
    int[] ExampleArray2 = new int[24];
    String tempci = "Battle of Midway";
    for(int i=0;i>=tempci.length();i++)
    int ascii = tempci.charAt(i); //Get ascii value for the first character.

    public class d1
         public static final void main( String args[] )
              int[] ExampleArray2 = new int[24];
              String tempci = "Battle of Midway";
              for(int i=0;i<tempci.length();i++)
                   int ascii = tempci.charAt(i);
                   ExampleArray2=ascii;
              for(int i=0;i<ExampleArray2.length;i++)
                   System.out.println(ExampleArray2[i]);

  • Splitting and type casting huge string into arrays

    Hello,
    I'm developing an application which is supposed to read measurement files. Files contain I16 and SGL data which is type casted into string. I16 data is data from analog input and SGL is from CAN-bus data in channel form. CAN and analog data is recorded using same scan rate.
    For example, if we have 6 analog channels and 2 CAN channels string will be (A represents analog and C represents CAN):
    A1 A2 A3 A4 A5 A6 C1 C2 A1 A2 A3 A4 A5 A6 C1 C2 A1 A2 .... and so on
    Anyway, I have problems reading this data fast enough into arrays. Most obvious solution to me was to use shift registers and split string in for loop. I created a for loop with two inner for loops. Number of scans to read from string is wired to N terminal of the outermost loop. Shift register is initialized with string read from file.
    First of the inner loops reads analog input data. Number of analog channels is wired to its N terminal. It's using split string to read 2 bytes at a time and then type casts data to I16. Rest of the string is wired to shift register. When every I16 channel from scan is read, rest of the string is passed to shift register of the second for loop.
    Second loop is for reading CAN channels. It's similar to first loop except data is read 4 bytes at a time and type casted to SGL. When every CAN channel from scan is read, rest of the string is passed to shift register of the outermost loop. Outputs of type cast functions are tunneled out of loops to produce 2D arrays.
    This way reading about 500 KB of data can take for example tens of seconds depending on PC and number of channels. That's way too long as we want to read several megabytes at a time.
    I created also an example with one inner loop and all data is type casted to I16. That is extremely fast when compared to two inner loops!
    Then I also made a test with two inner loops where I replaced shift register and split string with string subset. That's also faster than two inner loops + shift register, but still not fast enough. Any improvement ideas are highly appreciated. Shift register example attached (LV 7.1)
    Thanks in advance,
    Jakke Palonen
    Attachments:
    String to I16 and SGL arrays.vi ‏39 KB

    OK, there is clearly room for improvement. I did some timing and my two above suggestions are already about 100x faster than yours. A few teeaks led to a version that is now over 500x faster than the original code.
    A few timings on my rather slow computer (1GHz PIII Laptop) are shown on the front panel. For example with 10000 scans (~160kB data as 6+2) my new fastest version (Reshape II) takes 14 ms versus the original 7200ms! It can do 100000 scans (1.6MB data) in under 200 ms and 1000000 scans (15MB data) in under 2 seconds.
    I am sure the code could be further improved. I recommend the Reshape II algoritm. It is fastest and can deal with variable channel counts. Modify as needed.
    Attached is a LabVIEW 7.1 version of the benchmarking code, containing all algorithms. I have verified that all algorithms produce the same result (with the limitation that the cluster version only works for 6*I16+2*SGL data, of course). Remember that the reshape function is extremely efficient, because it does not move the data in memory. I have some ideas for further improvements, but this should get you going.
    Message Edited by altenbach on 08-05-2005 03:06 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    StringI16SGLCastingTimer.png ‏48 KB
    StringtoI16andSGLArraysMODTimer.vi ‏120 KB

  • Parse string into array for comparison

    Hi All,
    I am trying to parse a string message into an array of numbers so I can check if my event was successful.
    \FF\FE\01\FD\02\00\00\00
    I know I just need to read through and discard the \, but I don't know how to do that in Labview. I just need to check if the 6th byte = 00 or not.
    Thanks! I mostly need help with parsing in labview.

    Assuming this is a plain ASCII string containing the letters 0..F and "\" as delimiter, you can simply used "Spreadsheet string to array" with the following settings:
    Type= 1D U8 array
    format= %x
    delimiter= "\"
    One problem is the extra delimiter at the beginning, so use array subset to skip the first element.
    (EDIT: Ahh, Darin beat me with a similar solution. Mine's a little easier ).
    Message Edited by altenbach on 08-06-2009 04:30 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    StringToArray.png ‏13 KB

  • Turning parts of a string into rows in another table

    I need to extract unit codes that are stored in a string into rows in a new table as below
    From:
    Set_cd         sequence_number         rule_text
    KP106A         15432         {1234,4567,8910,1567}
    To:
    Set_cd         sequence_number         unit
    KP106A         15432         1234
    KP106A         15432         4567
    KP106A         15432         8910
    KP106A         15432         1567
    The strings will be of varying lengths but the layout will always be the same with the curley brackets and commas.
    Any ideas please?
    Thanx
    Rob.
    Edited by: Rob Mc on Sep 23, 2009 2:38 PM

    Something like this ->
    satyaki>
    satyaki>select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    PL/SQL Release 10.2.0.1.0 - Production
    CORE    10.2.0.1.0      Production
    TNS for Linux: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    Elapsed: 00:00:00.03
    satyaki>
    satyaki>
    satyaki>with ta_tab
      2  as
      3    (
      4      select 'KP106A' set_cd, 15432 sequence_number, '{1234,4567,8910,1567}' rule_text from dual
      5    )
      6  select set_cd,
      7         sequence_number,
      8         REGEXP_SUBSTR (replace(replace(rule_text,'{',''),'}',''), '[^,]+', 1, level) rule_part
      9  from ta_tab
    10  connect by level <= (
    11                         select length(regexp_replace(replace(replace(rule_text,'{',''),'}',''),'[^,]*'))+1
    12                        from ta_tab
    13                      );
    SET_CD SEQUENCE_NUMBER RULE_PART
    KP106A           15432 1234
    KP106A           15432 4567
    KP106A           15432 8910
    KP106A           15432 1567
    Elapsed: 00:00:01.02
    satyaki>
    satyaki>Regards.
    Satyaki De.

  • String into array in oracle

    Hi,
    I have value in a column in oracle table as "DE","DS","KJ".
    now,How can I get them into string array?
    Is there any API to get this ..
    Thanks
    Chat

    I have value in a column in oracle table as "DE","DS","KJ".
    now,How can I get them into string array?Do you mean that you have a single string with quotes and commas? If so you have to parse it to extract the constituent strings. Ostermiller has a library that does this sort of thing (Google ostermiller csv) and deals with the complexity of commas and quotes within the quoted parts.
    (If you know the string value consists of quoted section separated by commas, and there is no possibility of spaces getting in the way, you could split the string based on "," and then take substrings to remove the quotes.)
    You should pick one thread for this and stick to it. Put a message in the other linking to the thread you want to use.

  • How to compare array of String with column of a table

    Hi,
    i have a array of string(say array is of length 1000). I want to
    compare those string in array with one table column
            - whether that table column has a string
                            if yes
                                            do nothing.
                            if no
                                            then insert that string into table.
            - whether table has obsolete row i.e, the one present in table and
    not in array
                            then delete that row.
    How do i go about this, because i see, it is not feasible to loop
    through array and search table to find new string OR loop through each
    row from table to find some obsolete row
    How can i accomplish this task more feasibly(without running query for
    each string, for comparission)? Is there any way to find this kind of
    problem. I would have been easy if i had to compare two tables(with
    UNION and INTERSECT), but it is not the case.
    thanks,
    kath.

    I'm not sure, whether I understand your problem correctly. Only two comments:
    - if both arrays are sorted, all can be done running exactly once simultaneously through both arrays.
    - if the column is marked as UNIQUE, all column strings will be different. I.e. you cannot insert the same string a second time.
    Regards  Thomas

  • Req help in conversion of string to array of args

    Hi,
    i need help in converting a string into array of args just like command line args
    i have a string s1 = 12 13 56 etc
    now i want to copy that into an array a[]
    a[0] = 12
    a[1] = 13 etc
    Thanks for help

    U can use String tokenizer.Why prefer that over split?Yah Bobby u can use split too..
    J2SE 1.4 added the split() method to simplify the task of breaking a string into substrings, or tokens.
    Thanks BigDaddy.. I realized after you told.
    try this too..
    String str = "Your string";
    String[] arr = str.split (" ");
    for (int i=0; i < arr.length; i++)
    System.out.println (arr);

  • How to get the record set into array?

    Hi,
    I want to get the record set into array in the procedure and do the processing of the array later in procedure.
    below is the stored procedure i am working on:
    procedure bulk_delete_group(p_group_id in Array_GroupListID) as
    begin
    for i in p_group_id.first..p_group_id.last loop
    --Here I have to get the list of user id before deleting group
    SELECT user_id into *<SOME ARRAY>* FROM group_members WHERE group_id = p_group_id(i);
    DELETE group WHERE group_id = p_group_id(i);
    --Process the user id array after group deletion..
    end loop;
    end bulk_delete_group;
    Thanks in advance
    Aditya

    Something like this ->
    satyaki>
    satyaki>select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
    PL/SQL Release 10.2.0.3.0 - Production
    CORE    10.2.0.3.0      Production
    TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production
    Elapsed: 00:00:00.20
    satyaki>
    satyaki>
    satyaki>select * from emp;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          9999 SATYAKI    SLS             7698 02-NOV-08      55000       3455         10
          7777 SOURAV     SLS                  14-SEP-08      45000       3400         10
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-81       4450                    10
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7839 KING       PRESIDENT            17-NOV-81       7000                    10
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
    13 rows selected.
    Elapsed: 00:00:02.37
    satyaki>
    satyaki>create type np is table of number;
      2  /
    Type created.
    Elapsed: 00:00:03.32
    satyaki>
    satyaki>Create or Replace Procedure myProc(myArray np)
      2  is
      3    i   number(10);  
      4    rec emp%rowtype;  
      5  Begin  
      6    for i in 1..myArray.count
      7    loop  
      8      select *  
      9      into rec 
    10      from emp 
    11      where empno = myArray(i); 
    12     
    13      dbms_output.put_line('Employee No:'||rec.empno||' Name:'||rec.ename); 
    14    end loop; 
    15  End myProc;
    16  /
    Procedure created.
    Elapsed: 00:00:00.88
    satyaki>
    satyaki>
    satyaki>declare
      2    v np:=np(9999,7777);  
      3  begin  
      4    myProc(v);  
      5  end;
      6  /
    Employee No:9999 Name:SATYAKI
    Employee No:7777 Name:SOURAV
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.30
    satyaki>Regards.
    Satyaki De.

  • "converting strings into integers in a array"

    I'm really left scrating my head trying to figure this out.
    What I have right now is this
    public class NameManager
         private names[] collection; // collection of names
         private int count;
         public NameManager() // Creating an array which for now is empty
              collection = new names[1000];     
              count = 0;
              String [] collection = {"boston", "Springfield", "New Haven",
                        "New York", "Albany"};
    Its a namemanager for my road trip project which will be sort of like mapquest. What it does, or it's supposed to do is I have a array of names of cities, that represented as strings, in a array called, collection. What my proffeser wants me to do is turn the strings into integers, so in this elements in the array can be referenced .
    It's probably so easy that I'll want to kick myself when I find out how to do it , but for whatever reason , all the information have found on the internet seems to go right over
    If any body can give some idea of how to turn the string you see above into a set of intege s I would be so grateful.

    turn the string into the index in the array
    i.e.
    boston => 0
    springfield => 1
    New Haven => 2
    New York => 3
    Albany => 4I should've mention this before but I need the names to go along with the numbers.
    This is the directions from my proffesser, I know it's not the easiest to understand
    but hopefully It will give you a better idea of what I'm talking about.
    A name manager. This object turns strings into numbers. Every time a name is added to the name manager, it is checked to see if it has already been seen. If so, return the number previously assigned to the name. If not, increment the "number of known names" and return this number as well as remember the string for future reference. You can assume that there will be no more than 1000 names in the manager. Each name is a string.
    A city. A city is a simple object: the city has a name and a number (at present).
    I got most of this part done it just strings integers part that's getting me.

  • Table string to array

    Hi,
    I need to print out a specify device mac addres.
    I got the mac address in table form by command prompt as attached file, but there are more than one mac address listed out.
    The only mac address number i want to use, is the 4th mac address 00-04-A3-12-32-25.
    May i know how to get this 00-04-A3-12-32-25 mac address from the whole table string and list it in array?
    Appreciated your advice.
    Thanks.
    Solved!
    Go to Solution.
    Attachments:
    getmac.txt ‏1 KB

    Here is a VI I use to get strings out of a table that has a header with seperator line ( ======== )
    Feed your string into the String In. Feed the Seperator Char (in your case the =) and it will break out the table into an array that you can index to get what you want.
    Omar
    Attachments:
    [String] Find Column Headers Position and Width.vi ‏66 KB
    [String] Get Column Block.vi ‏15 KB
    [String] Remove BLANK Lines.vi ‏10 KB

  • Is there an easy way to convert a long string into an array?

    I can convert a long string into a 1-d array by parsing and using build array, but I would like to know if there is a function to make this easier.
    For example:
    from/   aaaaaaaabbbbbbbbccccccccdddddddd         (string of ascii)
    to/       an array that is 1-d with each element having eight characters
              aaaaaaaa
              bbbbbbbb
              cccccccc
              dddddddd
    Thank you.
    Solved!
    Go to Solution.

    Try something like this:
    (If you can guarantee that the string length is an integer multiple of 8, you an drop the two triangular modes in the upper left. )
    Message Edited by altenbach on 03-14-2010 06:40 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    ChopString.png ‏9 KB

  • How to put a String into a byte array

    How can i put a String into a byte array byte[]. So that i can send it to the serial port for output to an LCD display. Cheers David

    javadocs for String
    getBytes
    public byte[] getBytes()
    Encodes this String into a sequence of bytes using the platform's default charset, storing the result into a new byte array.
    Returns:
    The resultant byte arraySince:
    JDK1.1

  • Problem - insert JSON string into table in CLR function

    Hi
    I create a CLR function to insert JSON string into table.
    With this line 
    mt = JsonConvert.DeserializeObject<MyTable>(jsonStr.ToString());
    The class is OK (no error), but when I try to add the Assembly in Microsoft SQL Server Management Studio, it has error :
    Assembly 'newtonsoft.json, version=4.5.0.0, culture=neutral, publickeytoken=30ad4fe6b2a6aeed.' was not found in the SQL catalog.
    (I have Newtonsoft.Json in the Reference)
    Please help !
    Thanks

    Hi Bob
    Could you elaborate a bit more?
    I think the code is ok. The problem is when I deploy the Visual Studio creates/alters the assembly, and get the error
    Error:  SQL72014: .Net SqlClient Data Provider: Msg 6503, Level 16, State 12, Line 1 Assembly 'newtonsoft.json, version=6.0.0.0, culture=neutral, publickeytoken=30ad4fe6b2a6aeed.' was not found in the SQL catalog.
    ALTER ASSEMBLY [Database1]
        FROM 0x4D5A90000300000004000000FFFF0000B800000000000000400000000000000000000000000000000000000000000000000000000000000000000000800000000E1FBA0E00B409CD21B8014CCD21546869732070726F6772616D2063616E6E6F742062652072756E20696E20444F53206D6F64652E0D0D0A2400000000000000504500004C0103000DE411540000000000000000E00002210B010B000012000000060000000000008E3000000020000000400000000000100020000000020000040000000000000006000000000000000080000000020000000000000300608500001000001000000000100000100000000000001000000000000000000000003C3000004F00000000400000A802000000000000000000000000000000000000006000000C000000042F00001C0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000080000000000000000000000082000004800000000000000000000002E7465787400000094100000002000000012000000020000000000000000000000000000200000602E72737263000000A8020000004000000004000000140000000000000000000000000000400000402E72656C6F6300000C0000000060000000020000001800000000000000000000000000004
    An error occurred while the batch was being executed.
    Done building project "Database1.sqlproj" -- FAILED.
    This is my FillRow function. Without the bold line, the everything is fine. I can create the assembly, then create the SQL function. Done. When I call select from the SQL function, it returns 10 rows as expected.
    public static IEnumerable getTable(SqlString jsonStr)
            ArrayList resultCollection = new ArrayList();
            MyTable mt;
            //mt = JsonConvert.DeserializeObject<MyTable>(jsonStr.ToString());
            int c = 1;
            while (c < 10)
                mt = new MyTable();
                mt.GlobalId = c.ToString();
                mt.DateSet = "DS=!=" + c.ToString();
                mt.Timestamp = "TS==" + c.ToString();
                mt.PartnerId = "PI==" + c.ToString();
                mt.PartnerUserId = "PUI=" + c.ToString();
                mt.UserIP = "UIP=" + c.ToString();
                mt.UserAgent = "UG=" + c.ToString();
                mt.Referer = "R=" + c.ToString();
                resultCollection.Add(mt);
                c++;
            //resultCollection.Add(mt);
            return resultCollection;

  • Storing JSON string into Oracle table

    Hi,
    What is appropriate way to store JSON string into Oracle table?
    Regards
    Peter

    If JSON becomes more popular, ORACLE might write data cartridge extension for JSONDB (in the same way as XMLDB).
    Till then CLOB and NCLOB is your best choice, and leave the parsing in your application layer.

Maybe you are looking for

  • How do I get sent emails from iPhone to appear in sent emails on Mac Mail?

    Trying to set it up so when I send emails from my iPhone 3GS that they appear in my sent messages folder on the server in my Mail program on my computer. Any smooth ways to set this up? Thanks in advance. J.

  • How to place download link on jsp page to download files eg. Download PDF

    Hi, I have made an appliaction in struts 2 which creates PDF,its working fine now i want to place a link on my jsp page from where i can click and download that PDF file which i have created and store on my local location. Also i want to to know can

  • MobileMe Gallery Widget Broke, MobileMe Support says to call Applecare

    This one has me, and mobileme, stumped. The resulting pick list in the Mobileme Gallery widget has now become unsynced with the actual mobileme galleries online. So while I can update existing widgets on this page, I can't add a new one. A work aroun

  • Converting to Flash

    I use iMovie to import video from my video camera. I am interested in converting this video to flash once my editing is complete. Could someone please give me a suggestion on reliable and relatively inexpensive software for the conversion? I am inter

  • Debuggin in abap

    hai, can any one help me to know the step by step procedure for debugging in abap from the begining thanking you, vinu karthik