Splitting string values in query

all,
i cant remember this but my problem is like i have a collection of string values passed to my query like "X234234:X23466:X03287:X457675" , so my query should be able to split each data value and use in the filter as below,
select * from emp where EmpID in ("X234234:X23466:X03287:X457675")
so how do i split every individual value and pass in the filter?
thank you.

Gor_Mahia wrote:
onedbguru
I'll revisit and marks acordingly i.e helpful but the other solution worked for me...thank you.It may have worked for you, but TABLE(XMLSEQUENCE is deprecated functionality so should be avoided.
That's what happens when you take a 'correct' answer on face value rather than actually reading up on it and understanding if it really is a correct answer.
The issue you have described is the "Varying IN list" issue which is commonly asked here, and Tom Kyte's blog on it is a suitable reference for dealing with it.
Other methods are described in the FAQ: {message:id=9360009}
You would be better to re-visit the solutions and pick one that is better, that doesn't use deprecated functionality.

Similar Messages

  • Is there any function to split string value into diff junks

    Hi guys i have a string value as below
    14507|||Subterranean Masquerade||||||Subterranean Masquerade
    you can say ||| is a field delimiter.
    i want to split each field identified by ||| delimiter and store in a collection table.
    is there any easy way to that?
    Thanks
    Asif

    actually i want to use DIY$ dynamic view and what i did.
    1) I created a object type as xyz_row_type with 4 attributes.
    2) then i created a collection type xyz_tab_type of xyz_row_type
    3) now i want to create a function which will return me xyz_tab_type
    i am using a utl_file.get_line(file_name,f_line_txt)
    each line has the four elements delimited by '|||' shown below
    14522|||Lessig|||Minna|||Lessig, Minna
    i want to split each element for each attribute of xyz_row_type.
    How can i do this?

  • Split String value into internal table at Carriage return

    Hi All,
    I have given a string type context ( text edit  box ) to the user to enter the values. The data can have carriage returns also.
    My Requirement is that I want to split the data at carriage returns and store it in my tables.
    I tired with a constant value of '%CR_LF' as available in CL_ABAP_CHAR_UTILITIES but to no good result.
    Can the Experts suggest some solution?/??
    Thankx in advance.
    Regds,
    Srini

    Hi Srini,
    Have you looked at your string containing the text in the debugger to verify that you really have <CR>+<LF> (i.e. reflecting CL_ABAP_CHAR_UTILITIES=>CR_LF, which should be easily visible when looking at the hex codes of the string)? Maybe it's just a <LF> (i.e. CL_ABAP_CHAR_UTILITIES=>NEWLINE). Might be good to do a REPLACE first using a regular expression for identifying the line feeds and then doing the SPLIT.
    Cheers, harald
    p.s.: If you still cannot get it to work, provide some more details of what you're doing...

  • Splitting String values

    Dear Legends,
    I have a text field that I need to split.
    Requirement is I need to split on 30th letter.
    But If 30th letter ends in the middle of the word then give the whole word before space.
    So If I have following text then it should split equally:
    "Very popular for the beach in France, It is stylish and useful. Being so light and soft they are easy to pack for holidays and carry to the beach. They dry quickly and can also be re-used."
    First, It should split after
    1 to 30 letters
    Second 31 to 60
    Very popular for the beach in
    France, It is stylish and useful.(30 letters but include Everything before space)
    Being so light and soft they are(30 letters but include Everything before space)
    easy to pack for holidays and carry(30 letters but include Everything before space)
    to the beach. They dry quickly and
    can also be re-used.
    Also it needs to be dynamically count in values till at least 300 words.
    All your help is much appreciated.
    Kind regards,
    Aamir

    Hi Aamir,
    I had to do something similar on a 'pre-printed' form however I also had to account for the no. of lines that can be printed on the page dimensions. Here's a 'part' of the code that should do the splitting job:
    WhilePrintingRecords;
    local stringvar s := {String_Field_in_database};
    local stringvar array arr := split(s," ");
    local numbervar i;
    numbervar lcount;
    lcount := 1;
    local numbervar fixed := 30;
    local booleanvar nl := false;
    for i := 1 to ubound(arr) do
        If i = 1 then
            local stringvar nstring := nstring + trim(arr[i]) + " ";
            local numbervar rem := fixed - len(nstring);
        else if i <> 1 and i <> ubound(arr) then
            if len(arr[i]) <= rem then
                nstring := nstring + trim(arr[i]) + " ";
                rem := (fixed*lcount) - (len(nstring)+lcount);      
                stringvar s := nstring;
                numbervar t := rem;
            else
                nstring := rtrim(nstring) + chr(13) + trim(arr[i]) + " ";
                lcount := lcount + 1;
                nl := true;
                rem := (fixed)- len(arr[i] + " ");
        else if i = ubound(arr) then
            if len(arr[i]) <= rem then
                nstring := nstring + trim(arr[i]);
                rem := fixed - len(nstring);
            else
                nstring := nstring + chr(13) + trim(arr[i]);
                rem := fixed - len(arr[i] + " ");
    nstring;
    Hope this helps.
    -Abhilash

  • How to pass multiple query string values using the same parameter in Query String (URL) Filter Web Part

    Hi,
    I want to pass multiple query string values using the same parameter in Query String (URL) Filter Web Part like mentioned below:
    http://server/pages/Default.aspx?Title=Arup&Title=Ratan
    But it always return those items whose "Title" value is "Arup". It is not returned any items whose "Title" is "Ratan".
    I have followed the
    http://office.microsoft.com/en-us/sharepointserver/HA102509991033.aspx#1
    Please suggest me.
    Thanks | Arup
    THanks! Arup R(MCTS)
    SucCeSS DoEs NOT MatTer.

    Hi DH, sorry for not being clear.
    It works when I create the connection from that web part that you want to be connected with the Query String Filter Web part. So let's say you created a web part page. Then you could connect a parameterized Excel Workbook to an Excel Web Access Web Part
    (or a Performance Point Dashboard etc.) and you insert it into your page and add
    a Query String Filter Web Part . Then you can connect them by editing the Query String Filter Web Part but also by editing the Excel Web Access Web Part. And only when I created from the latter it worked
    with multiple values for one parameter. If you have any more questions let me know. See you, Ingo

  • How to retrieve query string value from the URL in my portlet

    Hi,
    When user clicks on "Advance Search", i am redirecting to page in the community. At the same i am adding some more values to the query string (to the URL).
    My URL will look like this.
    http://ctp-mc0149/portal/server.pt?space=CommunityPage&parentname=CommunityPage&parentid=0&in_hi_userid=200&cached=true&control=SetCommunity&PageID=202&CommunityID=200&searchType=2
    Now in one of my portlet in that page, i want to retrieve the query string values from the URL.
    Please help me regarding this.
    Thanks in advance.
    Thanks,
    sreekanth.

    Hi,
    Look at the following threads,
    For programmatically getting the iview properties,
    Programmatically getting iView Properties
    Also,
    Get Properties of IView Programmatically
    Permanent change of iView property programmatically
    Hope these threads help u.
    Regards
    Srinivasan T

  • Dynamic cell associated value as query string parameter in custom hyperlink property of KPI of scorecard in PPS SP2013

    Can we pass dynamic cell associated value [of scorecard] as query string parameter in custom hyperlink property of KPI of scorecard in PPS SP2013 , so that we can pass those values to another page 
    How to get those cell associated values and set these dynamic value as query string parameter in custom hyperlink property of KPI of scorecard in performance point services in sharepoint 2013

     I could somehow link to the table name, but that can be changed...  Any ideas?
    Not sure if this will help or not but maybe a little from several areas might point you in the right direction.
    If you are concerned about users changing the table name then you can define a name to reference the table and then if the user changes the table name then the Refers to automatically changes to the new table reference but your defined name remains the same.
    However, if users want to break a system even when you think you have it bullet proof the users come along with armour piercing bullets.
    Example:
    Insert a table (say Table1)
    Go to Define a name and insert a name of choice (eg.  ForMyTab1)
    Then click the icon at the right of the Refers to field and select the entire table including the column headers and it will automatically insert something like the following in the Refers to field.
    =Table1[#All]
    Now if a user changes the table name then Table1 will also automatically change.
    Example code to to reference the table in VBA.
    Sub Test()
        Dim wsSht1 As Worksheet
        Dim lstObj1 As ListObject
        Set wsSht1 = Worksheets("Sheet1")
        Set lstObj1 = wsSht1.ListObjects(Range("ForMyTab1").ListObject.Name)
        MsgBox lstObj1.Name
    End Sub
    Regards, OssieMac

  • Getting string values from DB query

    I am using the following code:
    <%@ page import="java.sql.*" %>
    <%
        String userName = request.getParameter("usernameField");
        String password = request.getParameter("passwordField");
        String connectionURL = "jdbc:mysql://localhost:3306/babbemployees?user=DBUser;password=MyPassword";
        Connection connection = null;
        Statement statement = null;
        ResultSet rs = null;
        Class.forName("com.mysql.jdbc.Driver").newInstance();
        connection = DriverManager.getConnection  (connectionURL, "DBUser", "MyPassword");
        statement = connection.createStatement();
        String queryString = "SELECT * FROM tbemployees where userID='"+userName+"'";
        rs = statement.executeQuery(queryString);   
        String isAuthenticated;
        if (userName == rs.getString("userID") && password == rs.getString("password")[0])
            isAuthenticated = "AUTHENTICATED";
        else
            isAuthenticated = "NOT AUTHENTICATED";
        rs.close();
    %>
    <html>
        <body>
        <h1><%= isAuthenticated %></h1>
        <hr>
        </body>
    </html>I am trying to get a String value for rs.getString() but for some reason this is not working out. Is there anything I can do to get the values for the queries in a String value?
    Thanks,
    Harlin

    When a ResultSet is returned to you, it is always positioned before the first row.
    You need to insert a rs.next(); after your executeQuery().

  • How to  get formated value from query

    i get value from query use the follow method
    Object obj1 = dataAccess.getValue(i,j,DataMap.DATA_UNFORMATTED);
    Object obj1 = dataAccess.getValue(i,j,DataMap.DATA_FORMATTED);
    the first method retrun a value '1666.0',
    the second method return a value null
    but i want to get the value '1,666'.
    who can tell me how can get the formated value?

    Ahu,
    An implementation of DataAccess is not required to support all DataMap constants. For example, the OLAP-based Query object does not support DataMap.DATA_FORMATTED. To find out which DataMaps are supported for a particular implementation, you can call the DataDirector's getSupportedDataMap method.
    If you have an Crosstab instance, there is a way to get the formatted cell value, based upon the formatting rules associated with the Crosstab. Get the GridViewFormatManager reference from the Crosstab, and call its formatDataValue method to return a String representation of the formatted data value.
    Hope this helps,
    djb

  • A more efficient way to assure that a string value contains only numbers?

    Hi ,
    I'm using Oracle 9.2.0.6.
    I was curious to know if there was any way I could write a more efficient query to determine if a string value contains only numbers.
    Here's my current query. This SQL is from a sub query in a Join clause.
    select distinct cta.CUSTOMER_TRX_ID, to_number(cta.SALES_ORDER) SALES_ORDER
                from ra_customer_trx_lines_all cta
                where length(cta.SALES_ORDER) = 6
                and cta.SALES_ORDER is not null
                and substr(cta.SALES_ORDER,1,1) in('1','2','3','4','5','6','7','8','9','0')
                and substr(cta.SALES_ORDER,2,1) in('1','2','3','4','5','6','7','8','9','0')
                and substr(cta.SALES_ORDER,3,1) in('1','2','3','4','5','6','7','8','9','0')
                and substr(cta.SALES_ORDER,4,1) in('1','2','3','4','5','6','7','8','9','0')
                and substr(cta.SALES_ORDER,5,1) in('1','2','3','4','5','6','7','8','9','0')
                and substr(cta.SALES_ORDER,6,1) in('1','2','3','4','5','6','7','8','9','0')This is a string where I'm finding A-Z-a-z characters and '/' and '-' characters in all 6 positions, plus there are values that are longer than 6 characters. That's what the length(cta.SALES_ORDER) = 6 is for. Also, of course. some cells are NULL.
    So the question is, is there a more efficient way to screen out only the values in this field that are 6 character numbers or is what I have the best I can do?
    Thanks,

    I appreciate all of your very helpfull workarounds. The cost is a little better in all cases than my original where clause.
    To address the discussion that's popped up about design from this question, I can say a few things that should clear , at least, my situation up.
    First of all this custom quoting , purchase order , and sales order entry system WAS written by a bunch a of 'bad' coders who didn't document their work and then left. We don't even have an ER diagram
    The whole project that I'm only a small part of is literally trying to put Humpty Dumpty together again and then move it from a bad custom solution into Oracle Applications.
    We're rebuilding, documenting, and doing ETL. This is one of your prototypical projects from hell.
    It's a huge database project so we're taking small bites as a time. Hopefully, somewhere right before Armageddon hits, this thing will be complete.
    But until then,..., well,..., you know the drill.
    Thanks Again.

  • Problem using & inside string in a query

    hi all, i have a problem with one of my query.
    i try using an & inside a string in a query and sqlplus and toad prompt me to enter a value. it is reconizing it as input. this is my query
    select department_name from dept where dept_name = 'S&R';
    how can write this query without sqlplus/toad asking me to enter a value for :R
    i tried to escape & by using 'S\&R' but nothing happen.

    In SQL*Plus you SET DEFINE OFF like this:
    SQL> set define off
    SQL> select 'S&R' from dual;
    'S&
    S&R(can't help you with Toad)

  • HELP URGENT:; Splitting strings in servlets

    hi ...
    I am trying to access the below servlet from another servlet in iplanet . I have to access a file and arrange the '|' delimited data in the file in a table format like in html ...
    I have used my own function inside the servlets which splits a string based on character ...But I always get
    Internal error: exception thrown from the servlet service function (uri=/servlet/ReportsDataServlet): java.lang.NullPointerException, Stack: java.lang.NullPointerException
    at ReportsDataServlet.split(ReportsDataServlet.java:82)
    at ReportsDataServlet.doPost(ReportsDataServlet.java:56)
    at ReportsDataServlet.doGet(ReportsDataServlet.java:14)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.iplanet.server.http.servlet.NSServletRunner.invokeServletService(NSServletRunner.java:919)
    at com.iplanet.server.http.servlet.NSServletRunner.Service(NSServletRunner.java:483)
    The sample code is shown below....I get the same error when i tries with stringokenizer as well....Pls help me fix this.....
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, Se
    rvletException
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    cont=getServletContext();
    out.println("<html><head><title>Reports Data</title></head><body bgcolor=DBD0E2>");
    String repType = request.getParameter("Rep");
    String mon = request.getParameter("month");
    String day = request.getParameter("day");
    String year = request.getParameter("year");
    String repName = repType+"."+mon+"-"+day+"-"+year+".txt";
    BufferedReader in = new BufferedReader( new FileReader("/home/lnayar/baais/xmlServlet/"+rep
    Name));
    String st;
    st = in.readLine();
    cont.log(st);
    int c =0;
    out.println("<table border=\"3\" cellpadding=\"0\" cellspacing=\"0\" width=\"800\"><tr><td>L
    ATA</td><td>WC CLLI</td><td>WC NAME</td><td>ADSL_LOCATION</td><td>ATM FLAG</td><td>ATM RELIEF DATE</td><t
    d>FRAME FLAG</td><td>FRAME RELIEF DATE</td><td>GOLD FLAG</td><td>GOLD RELIEF DATE</td><td>OVERLAY INDICAT
    OR</td><td>COUNT</td></tr>");
    while (st != null)
    c++;
    st = in.readLine();
    StringTokenizer stt = new StringTokenizer(st);
    out.println("<tr>");
    while (stt.hasMoreTokens())
    //out.println("<td>"+stt.nextToken("|")+"</td>");
    out.println("<td>hello</td>");
    out.println("</tr>");
    while (st != null)
    c++;
    st = in.readLine();
    out.println("<tr>");
    Enumeration en = split(st,"|");
    while(en.hasMoreElements())
    out.println("<td>"+en.nextElement()+"</td>");
    out.println("</tr>");
    cont.log("out while");
    out.println("</table>");
    out.println("</body></html>");
    public Enumeration split (String str, String delim)
    Vector v = new Vector();
    int pos_1;
    int pos_2;
    //Set initial delimiter positions...
    pos_1 = 0;
    pos_2 = 0;
    //Start chopping off bits from the string
    //until left boundary reaches the length of string
    while ( pos_1 <= str.length() )
    pos_2 = str.indexOf(delim, pos_1);
    if ( pos_2 < 0 )
    pos_2 = str.length();
    String sub = str.substring (pos_1, pos_2);
    pos_1 = pos_2 + 1;
    v.addElement(sub);
    return v.elements();
    d deeply appreciate if soeone could take a look at the code and tell me exactly where i am going wrong ..... Its URGENT ...
    Thx
    klv

    But there is the while statement which filters null
    values..Which is useless in your case, because you proceed to change the value of st to something else which you don't check for null.
    At any rate, what you have to do is this:
    1. Look at the stack trace to find the line number where the error occurs.
    2. Look at that line in your code.
    3. Look at each object variable in that line. Find out how it became null and fix that.

  • Retrieving Strings from Database query ??

    Hi,
    The problem i'm having at the moment is, with the following code:
    connect = DriverManager.getConnection("jdbc:mysql://ash.bc.ic.ac.uk/KEGG_devel?user=null&password=guest");
    Statement stmnt1 = connect.createStatement();
    ResultSet rs1 = stmnt1.executeQuery("SELECT DISTINCT A.ReactID, A.ECid FROM ECReact As A INNER JOIN ECReact As B ON A.ECid = B.ECid AND A.id <> B.id ");
    System.out.println("the size of rs1 is: " +rs1.getFetchSize());
    while (rs1.next()){
    String reactionId = rs1.getString("ReactID");
    String ecNumb = rs1.getString("ECid");
    System.out.println("the value of ecNumb is :" +ecNumb);
    I want to be able to retrieve a String from the query called ECid - an example of such a String would be 4.2.1.86 or 4.2.1.44. However, when i'm Storing the "ECid" in a String called ecNumb and then printing the String all that i get returned is the last 2 digits !
    Does anyone know how to resolve this ??
    Thanks very much for any help
    (oh yeah + for future reference, how do i highlight code in topics??)

    to highlight code... isSimple...
    [bold] [ code][bold]
    your code pasted in here
    [bold] [ / code][bold]
    but leave out the spaces in the []
    i had to add them to get [ c o d e ] to show up.
    m.

  • How to insert some strings in a query with the clausule 'in' in a procedure

    Hello fellows.
    Do you know how to insert some strings in a query with the clausule 'in' in a procedure (with a variable)?.
    I tell us my problem with an example:
    I want to use this select but introducing a variable instead the 'value1', 'value2':
    select * from table1 where field1 in ('value1', 'value2');
    if I declare the variable var1 as:
    TC_VAR1 CONSTANT VARCHAR2(50) := '''value1'',''value2'''
    and I use it as:
    select * from table1 where field1 in (TC_VAR1);
    It doesn't work because Oracle takes TC_VAR1 as an all string. I think Oracle takes it as this:
    select * from table1 where field1 in ('value1, value2');
    If I use the data type TABLE, I don't know how to use well:
    TYPE varchar2_table IS TABLE OF VARCHAR2(10);
    tb_var varchar2_table;
    select * from table1 where field1 in (tb_var);->It returns an error and there ins't an method that it returns all values.
    A curious case is that if I have a sql script (for example script1.sh) with this query:
    select * fromt able1 where field1 in (&1)
    and I invoke this script as
    script1.sh "'''value1'',''value2'''". It works
    Can anybody helps me?.
    Thanks.

    Thanks to all. Really.
    First, sorry for my English. It's horrible. Thank to all for understand it (my English).
    I've resolved my problem with these links:
    ORA-22905: cannot access rows from a non-nested table item
    and
    http://stackoverflow.com/questions/896356/oracle-error-ora-22905-cannot-access-rows-from-a-non-nested-table-item
    At last, I have used someting like this:
    DECLARE
    number_table_tmp NUM_ARRAY:=NUM_ARRAY(410673, 414303, 414454, 413977, 414042, 414115, 413972, 414104, 414062);
    BEGIN
    FOR c1 IN (SELECT par_id, 1 acc_vdo_id FROM SIG_VIS_CAM
    WHERE par_id IN (SELECT * FROM TABLE(number_table_tmp))
    UNION ALL
    SELECT par_id, 2 acc_vdo_id FROM SIG_ACCAO a
    WHERE par_id IN (SELECT * FROM TABLE(number_table_tmp))) LOOP
    NULL;
    END LOOP;
    END;
    but first I had to create the type NUM_ARRAY like this:
    CREATE TYPE subjectid_tab AS TABLE OF NUMBER INDEX BY binary_integer;
    THANK YOU, GUYS. YOU ARE THE BESTS. ;-)
    Edited by: user12249099 on 08-sep-2011 7:37
    Edited by: user12249099 on 08-sep-2011 7:37

  • Insert String Using SQL Query

    Hi, EveryOne,
    I tried to insert(update) a string data type using Fixed SQL Query as, for a example:
    insert into Masters(MasterName) values([Param.1])
    In html form I enter a value in field and press button to call the function. But if enter in the field a String value - nothing inserted in table but if I enter Number - everything works fine. I tried to use commas but the effect is the same.
    Thnks,
    Serj

    Hello Sergey,
    Ryan's sql statement is right. The ' sign is used to mark the [Param.1] as a string.
    The sql statement (connection) is language independent, but you have to make sure that you mark up strings and timestamps in the correct way.
    In your first statement
         Masters(MasterName) values([Param.1])
    xMII will replace [Param.1] with the value you type in("yourvalue"). For strings("yourvalue") it will look like this
         Masters(MasterName) values(yourvalue)
    this should bring back a sql error. You can try it in another sql client.
    Hope this help as an explanation.
    Regards,
    Martin

Maybe you are looking for

  • IPad 2 to iOS 5.0.1 now no Apps will start

    I just updated my mothers iPad 2 to iOS 5.0.1. Now when she trys to run any of her games the screen will flash and nothing will happen. So of the base Apps work, but anything that was downloaded from the App store will not run. Is there any fix for t

  • Is 7.5 mm ssd  FIT for macbook pro ??

    hi  im using macbook pro early 2011. now i want to upgrade my macbook pro. can i use 7.5 mm SSD harddisk on my macbook ?? is 7.5 mm SSD fit for macbookpro ?? Best Regards. Message was edited by: uzk Message was edited by: uzk

  • How do i get purchased music off my iphone into my itunes library?

    help! my itunes library can't locate these tunes i purchased. does anyone have ideas? thanks! chris

  • Problem in BDC for CA02

    hello all,          i am doing BDC for change routing (ca02) transaction. in that my need is to assign PRT allocation for operations. i have written a program for it but if suppose for a particlular operation i want to assign PRT and if there are no

  • Help for on mapping - Std function or UDF?

    Hi All, I am working on DELVRY03 Idoc (outbound) n doing mapping betweeb Idoc and legacy structure. In delivery line item we have lineitem quantity field E1EDL24-LFIMG. Let say if we have 3 line items with LFIMG values 5,10,15...we need add up all th