Sort ArrayList on multiple values

Hi all!
i'm trying to sort an ArrayList that contains a list of beans with a bunch of properties.
i think that the comparator should be written like this:
    protected class CategoryComparator implements Comparator {
        public int compare(Object o1, Object o2) {
            Category cat1 = (Category)o1;
            Category cat2 = (Category)o2;
            return cat1.getCategoryName().compareTo(cat2.getCategoryName()) & cat1.getCategoryId().compareTo(cat2.getCategoryId());
    }where Category is the bean, getCategoryName and getCategoryId return two strings. Is that right to get the list sorted on both the two fields?
Thanks!

No, it's not. Assuming categoryName is of higher priority, you want int comp = cat1.getCategoryName().compareTo(cat2.getCategoryName());
if (comp != 0) return comp;
return cat1.getCategoryId().compareTo(cat2.getCategoryId());

Similar Messages

  • Sorting ArrayList multiple times on Multiple Criteria

    I have an arraylist that is sorted with Collection.sort() calling the ComparTo() included below. CompareTo sorts the file on totalLaps, totalSeconds, and etc.. The question is how do I change the sort criteria later in my process so that the arraylist is sorted on sequence number (the first field and a long number)? The only way I can currently think of doing it is to copy the array and create a separate class file like RaceDetail2 that implements a different CompareTo. To me that seems ridiculous!
    I've self tought myself Java using the online tutorials and a few books so sometimes I find I have some basic gaps in knowledge about the language. What am I missing? Seems like it should be simple.
    private ArrayList detailsArrayList = new ArrayList( );
    // Sort arraylist using compareTo method in RaceDetail file
    Collections.sort(detailsArrayList);
    public class RaceDetail implements Comparable, Cloneable {
         public RaceDetail( long seqNum, String boatNumText, int lapNum, String penalty, String question, long seconds, int totalLaps, long totalSecs, long lastSeqNum, long avg, long interval )
    public int compareTo( Object o )
         RaceDetail rd = (RaceDetail) o;
         int lastCmp = (totalLaps < rd.totalLaps ? -1: (totalLaps == rd.totalLaps ? 0: 1));
         int lastCmpA = boatNumText.compareTo(rd.boatNumText);
         int lastCmpB = (lapNum < rd.lapNum ? -1: (lapNum == rd.lapNum ? 0 : 1 ));
         int lastCmpC = (totalSecs < rd.totalSecs ? -1 : (totalSecs == rd.totalSecs ? 0 : 1 ));
         int lastCmpD = (seqNum < rd.seqNum ? -1 : (seqNum == rd.seqNum ? 0 : 1 ));
         int lastCmpE = (seconds < rd.seconds ? -1 : (seconds == rd.seconds ? 0 : 1 ));
         int lastCmpF = (lastSeqNum < rd.lastSeqNum ? -1 : (lastSeqNum == rd.lastSeqNum ? 0 : 1 ));
         // TotalLaps - Descending, TotalSeconds - ascending, lastSeqNum - ascending
         // Boat - Ascending, Second - ascending, seqNum - ascending
         return (lastCmp !=0 ? -lastCmp :
              (lastCmpC !=0 ? lastCmpC :
                   (lastCmpF !=0 ? lastCmpF :
                        (lastCmpA !=0 ? lastCmpA :
                             (lastCmpE !=0 ? lastCmpE :
                                  lastCmpD)))));
    }

    Thanks talden, adding the comparator below in my main program flow worked and now the arraylist sorts correctly. A couple of additional questions. I tried to place this in my RaceDetail class file and received a compile error so placed it in the main program flow and it worked fine. For organization, I would like to place all my sort routines together. Is there some trick to calling this method if I place it in my RaceDetail? Am I even allowed to do that?
    dhall - just to give you a laugh, this arraylist populates a JTable, uses a TableModel, and the TableSorter from the tutorial. Sorting works great in the JTable. Problem is I have to sort the arraylist a couple of times to calculate some of the fields such as lap times and total laps. I went through the TableSorter 5 or 6 times and never could figure out how to adapt it for what I wanted to do. So here I am using an example in my program and can't interpret it.
    Collections.sort( detailsArrayListLeft, SORT_BY_SEQUENCE );
    static final Comparator SORT_BY_SEQUENCE = new Comparator() {
    public int compare ( Object o1, Object o2 )
         RaceDetail rd1 = (RaceDetail) o1;
         RaceDetail rd2 = (RaceDetail) o2;
         return (rd1.seqNum() < rd2.seqNum() ? -1 : (rd1.seqNum() == rd2.seqNum() ? 0 : 1 ));

  • Multiple Values per Key - PLEASE HELP!!

    hi. im trying to setup a TreeMap so it contains multiple values for each key using a List to store these values and a string as a key to reference them. however, although it compiles, i recieve a ClassCastException: java.util.ArrayList error when it runs. heres some of my code:
    Map resultRelation = new TreeMap();
    List list = new ArrayList();
    list.add(value1);
    list.add(value2);
    resultRelation.put(Key, list);
    i cant seem to find much useful information on this sort of thing. any help would be appreciated.

    well after hours of labouring, it turns out that the code i posted is working but the problem is actually to do with printing out the values stored in the array. it was rather stupid of me but before i had created a print method which printed the key and its value from the map, assuming the value was one string not a List, and i hadn't updated it =) so the ClassCastException error was occuring because i was trying to cast the value (which is really a List) to a string in order to print it.
    heres my updated printRelation method code as follows:
    private static void printRelation(Map relation) {
    Iterator keyIter = relation.keySet().iterator();
    Iterator valueIter = relation.values().iterator();
    while(keyIter.hasNext() == true) {
         String primaryKey = (String)keyIter.next();
         List foreignKey = (List)valueIter.next();
    ConsoleIO.out.print(primaryKey); // ignore the ConsoleIO stuff. the key prints no prob.
    Iterator iter = foreignKey.iterator();
    while(iter.hasNext() == true) {
    String value = (String)iter.next();
              ConsoleIO.out.print(value);
    at the moment im only adding 1 value to the List as shown in my previous post. e.g.
    list.add(foreignKey1);
    all this works BUT im getting the wrong results. instead of printing out the key and only its values, its printing out the key and ALL the values from the text file im using. i think its either got something to do with my while loop or my casting of the List but this is all new ground for me =)
    thanks.

  • How to return multiple values from dialog popup

    hi all
    I'm using ADF 10g. I have a requirement that I have to return multiple values from a dialog.
    I have a page containing a table with a button which calls the dialog. The dialog contains a multi-select table where i want to select multiple records and add them to the table in the calling page.
    In the backing bean of the calling page, I have the returnListener method.
    I am thinking that I have to store the selected rows from dialog in an array and return that array to the returnListener...but I don't know how to go about it with the code.
    Can someone help me out with it?
    thanks

    Hi Frank,
    I'm trying to implement your suggestion but getting comfused.
    AdfFacesContext.getCurrentInstance().returnFromDialog(null, hashMap) is called in ActionListener method, from what I understood.
    ReturnListener method already calls it, so no need to call explicitly.
    Okay here's what i'm doing.
    command button launches the dialog on the calling page.
    In the dialog page, there is a button "select", which when i click, closes the dialog and returns to calling page. I put a af:returnActionListener on this button, which logically should have a corresponding ReturnListener() in the calling page backing bean.
    Now I have 3 questions:
    1. do i have to use ActionListener or ReturnListener?
    2. where do I create the hashMap? Is it in the backing bean of the dialog or in the one of calling page?
    3. how do I retrieve the keys n values from hashmap?
    please help! thanks
    This is found in the backing bean of calling page:
    package mu.gcc.dms.view.bean.backing;
    import com.sun.java.util.collections.ArrayList;
    import com.sun.java.util.collections.HashMap;
    import com.sun.java.util.collections.List;
    import java.io.IOException;
    import java.util.Map;
    import javax.faces.application.Application;
    import javax.faces.application.ViewHandler;
    import javax.faces.component.UIViewRoot;
    import javax.faces.context.FacesContext;
    import javax.faces.el.ValueBinding;
    import javax.faces.event.ActionEvent;
    import mu.gcc.dms.model.services.DMSServiceImpl;
    import mu.gcc.dms.model.views.SiteCompaniesImpl;
    import mu.gcc.dms.model.views.SiteCompaniesRowImpl;
    import mu.gcc.dms.model.views.lookup.LkpGlobalCompaniesImpl;
    import mu.gcc.util.ADFUtils;
    import mu.gcc.util.JSFUtils;
    import oracle.adf.model.BindingContext;
    import oracle.adf.model.binding.DCBindingContainer;
    import oracle.adf.model.binding.DCIteratorBinding;
    import oracle.adf.view.faces.context.AdfFacesContext;
    import oracle.adf.view.faces.event.ReturnEvent;
    import oracle.adf.view.faces.model.RowKeySet;
    import oracle.binding.AttributeBinding;
    import oracle.binding.BindingContainer;
    import oracle.binding.OperationBinding;
    import oracle.jbo.AttributeDef;
    import oracle.jbo.Key;
    import oracle.jbo.Row;
    import oracle.jbo.RowIterator;
    import oracle.jbo.RowSetIterator;
    import oracle.jbo.domain.Number;
    import oracle.jbo.server.java.util.Iterator;
    public class CompanyList {
    private BindingContainer bindings;
    private Map hashMap;
    DMSServiceImpl service =(DMSServiceImpl)ADFUtils.getDataControlApplicationModule("DMSServiceDataControl");
    SiteCompaniesImpl siteCompanyList = service.getSiteCompanies();
    LkpGlobalCompaniesImpl globalCompanyList = service.getLkpGlobalCompanies();
    public CompanyList() {
    public BindingContainer getBindings() {
    return this.bindings;
    public void setBindings(BindingContainer bindings) {
    this.bindings = bindings;
    *public void setHashMap(Map hashMap) {*
    *// hashMap = (Map)new HashMap();*
    this.hashMap = hashMap;
    *public Map getHashMap() {*
    return hashMap;
    public String searchCompanyButton_action() {
    BindingContainer bindings = getBindings();
    OperationBinding operationBinding =
    bindings.getOperationBinding("Execute");
    Object result = operationBinding.execute();
    if (!operationBinding.getErrors().isEmpty()) {
    return null;
    return null;
    *public void addCompanyActionListener(ActionEvent actionEvent){*
    AdfFacesContext.getCurrentInstance().returnFromDialog(null, hashMap);
    public void addCompanyReturnListener(ReturnEvent returnEvent){
    //how to get hashmap from here??
    public String addCompanyButton_action() {
    return "dialog:globalLovCompanies";
    }

  • How to get multiple values using HttpSession.getAttribute(java.lang.String)

    Hey Guys
    I'm trying to find a way to get multiple values using the following method
    HttpSession.getAttribute(java.lang.String)
    Here's the scenerio. Its a already written application and now i'm trying to make some changes. earlier in the jsp page a combo box was used and value was retrieved in the servlet using the getAttribute method of Session. Now I'm using a html multiple selection list and have to retrieve all the values selected in the list in the servlet. Can anyone please suggest me how to do that. HTTPRequest class has a method getParameterValues which will let me do that but i have to do is using HTTPSession.
    Thanks for your time to read this

    I'm not sure what you are trying to do. You can only use session.getAttribute to retrieve something that has already been stored in the session with a previous setAttribute. If you need to store multiple values under one attribute name using setAttribute, you can store an array, or an ArrayList or whatever type of Collection you want. The request.getParameterValues method is the only way you can retrieve form parameters than can have multiple values. If the servlet hasn't already processed these parameters and put them into the session for you, you have to use request.getParameterValues.

  • OBIEE 11g Unable to browse multiple value hierarchy for analysis.

    Hi All,
    We are using OBIEE 11g Value Hierarchy feature to display GL Segment Hierarchies.
    -     We have set the hierarchies to be Ragged and Skipped Levels in the RPD Business Model.
    -     We have dragged the hierarchies from Business Model to Presentation Layer.
    -     When selecting the hierarchies during Analysis, the first hierarchy that is browsed appears correctly. The next hierarchy when browsed just hangs.
    For example:
    Step 1: Browse Hierarchy1 (Block). The values show correctly.
    Step 2: Browse Hierarchy2 (Account). The hierarchy does not open with a blinking circle remaining forever.
    Alternatively;
    If we selected, Hierarchy 2(Account) first, the hierarchy shows correctly, but when selecting Hierarchy1 (Block) a blinking circle appears and remains for ever without opening the hierarchy.
    The nqquery.log shows correct result. My suspicion is that the issue is on the front end presentation services/javascript side.
    Is there any additional setup/configuration required to open multiple value hierarchies during analysis.
    Thanks and Regards,
    Sasi

    I have a pretty good guess at the hanging problem, unforntunitly i have no solutions yet.
    I having same type of issue, hangs when building filters on for 2nd or 3rd dim table.. I can see obiee fireing off the query to populate the dropdown by running
    select distinct on and joining to the fact table and dimensions that the users usually have selecte prior to start creatinng the filters.
    It is sort of like doing a intra dimension filter.. Sounds good but if user does not cut way down on number of fact rows by the time 2nd filtered column is selected the generated query to populate the drop down can run and run.
    OBI SE Once and discoverer dd not do this, at least not out of the box.

  • Creating Profile type report that hold fields with multiple values

    Really hoping someone can please help me out as I am very new to Crystal Reports.
    We use Maximizer CRM and we have been in need of some custom reports to rule out risk for regulators. I contacted Max and they suggested the only possible way is to create through Crystal. Its been almost one month already and I still cannot for the likes of me get this report operating properly. I have been inside and out on all sorts of forums, posted topics but no luck! So I will give it one more attempt in hopes that one of you geniuses can show me the way.
    In Maximizer CRM there is date, numeric, alphanumric and table. Our table fields items can be set to either single value or multi-value. So in crystal i did a default join of Client.tbl and the user-defined fields from view and joined the client id and contact number from all the view fields to client table. See Image:
    and I have dragged all the relevant fields in rows (in details section) rather then columns because we would be reporting on more then 1 record at a time. My problem is - If there is a table with multiple items selected (values), the records triple in count and it will show the same record over and over with just single field value changing at a time.
    The formula field you see in the image is from when I posted a discussion and Abhilash assisted me by providing the formulas I should add:
    1) Create a formula with this code and place this on the Details Section:
    whileprintingrecords;
    stringvar s := s + {field_with_multiple_values} + ", ";
    2) Next, move all the fields (except the formula field above) from the Details section to the Report Footer
    3) Create a formula with this code and place this on the Report Footer. This field would replace the existing field that contains multiple values:
    whileprintingrecords;
    stringvar s;
    Left(s, len(s)-2);
    This method is not working out for this type of report. When I add the formula Crystal is still counting my 2 records as 5 records but I can only view it as a single record and the multi-field has all the values for both records and displaying as a single record. See image:
    Can anyone please assist and advise where I am going wrong?
    -Jared

    Hi Jared,
    Thanks for taking down memory lane that is Maximizer.  Nice to see their table structure hasn't been simplified in the last 20 years.
    If I understand what's happening, you should only see 2 records and not 5.  That means your joins are creating duplicate records.  For now I'm going to skip over trying to optimize your query because I still have bad dreams of linking Maximizer tables.
    There are a couple of ways to work around the duplicates, one is to create a group and instead of having your formula in the Detail section, put it in the Group Header.  The question is what would you create your group on that would get you a unique record?
    If you know where the duplicates are coming from, create a Record Selection Formula that will remove the duplicates.
    There is also the menu option Database | Select Distinct Records.  I've never really had success with this one but there's no harm in giving it a shot.
    I would have you try and find which table or combination of tables is generating the duplicates but that requires playing with your links.  Normally I'd start by adding one table at a time and dropping one field onto the report.  If it doesn't repeat then add another table and field and repeat until you get your duplicates.  Once you know where they are coming from then you can either drop that table from your query or create a selection formula that removes the duplicates.
    Good luck,
    Brian

  • How can I create a hashmap() with multiple values for the same key?

    I am trying to write an application that will us something like a Map() with multiple values but some have the same key. Is this possible?

    i had the same question. just create a List, add all the values u want to it, and then put the List into the map like u would a normal single value. e.g.
    List list = new ArrayList();
    list.add(value1);
    list.add(value2);
    map.put(key, list);
    i bet u r doing the same course as i am =)

  • How do you lookup multiple values in different columns based on variable criteria?

    Essentially, I'd like to be able to do a Vlookup but instead of searching for one value only, search for multiple values in separate columns. A smaller version of my current spreadsheet as an example...
    Attack Type ->
    Fire
    Water
    Grass
    Fire
    1/2x
    2x
    1/2x
    Water
    1/2x
    1/2x
    2x
    Grass
    2x
    1/2x
    1/2x
    Fire/Water
    1/4x
    1x
    1x
    Fire/Grass
    1x
    1x
    1/4x
    Grass/Water
    1x
    1/4x
    1x
    The headers are the attack types and the list of types to the left are the receiving Pokemon. Fire does half damage (1/2x) to fire types, Water does double damage (2x) to fire types, etc. I'd like to be able to search for specific damages for each type. For example, I'd like to find a Typing that recieves half (1/2x) damage from Fire-type attacks but also recieves double (2x) from Grass-type attacks. I do want more than just two search criteria though seeing as the actual table is much, much larger.
    I've tried assigning number values to each damage multiplier and then merging all of them together for a specific typing and doing a VLOOKUP based on checkboxes determining what damage multiplier I want in a few specific types, the rest being filled in to the standard of 1x but the result isn't correct most of the time.

    Hi Mitchell,
    VLOOKUP can be set for accept either an 'exact match' or a 'close match'.  Your 17 digit 'number' is actually a 17 character text string (Numbers can handle numbers to a precision of only 15 places). Provided all 17 digits are present, sorting should be the same as for numerical values—the leftmost character is the most significant.
    As a text string, your 'number' is sorted/evaluated alphabetically. A 'close match' accepts the 'largest value that is less than or equal to the search value'.
    If your search term is 000200000 (a 9 character string), several 'wrong' answers will fit the 'close match' criteria, including all of those listed below:
    000200000 (the 'correct' match)
    0000xxxxx (x may be any of the three acceptable values)
    0001xxxxx (x may be any of the three acceptable values)
    The main problem here is that digits in a number (or characters in a text string) have decreasing significance related to their distance from the beginning of the string/number. You want a search in which each character has the same significance as each of the others when compared to the search key. To do that, you need to compare each character in the search string with the character in the same position in the similar string for each type of Pokemon, then take a count of the matches or a sum of the differences.
    Here's one approach:
    Column A contains labels.
    Column B, the 17 digit search term, created in whatever manner you wish, and the similar 17 digit string for each of the characters.
    Columns C through S contains a formula that detines, using subtraction, the difference between each digit of the search term and the corresponding digit of each character's profile.
    Column C uses SUM() to calculate the total of columns C to S for each row.
    T1 uses =MIN(T) to calculate "least different" profile.
    Column A is a Header column; Row 1 is a Header row.
    Formulas:
    C2, and filled right to S2, then down to the last row of data:
    =ABS(MID($B$1,COLUMN()-2,1)-MID($B2,COLUMN()-2,1))
    T1: =MIN(T)
    T2, and filled down column T: =SUM(C2:S2)
    The conditional formatting rule set for all body cells in column T is shown below the table.
    This may be enough to get you started. Formulas can be tweaked to produce results more closely matching what you're looking for, if necessary.
    Regards,
    Barry

  • How to Map one key to multiple values

    Hello Everyone
    Let's say I have a System. to access this system, one needs a username and a password. Now i have a Hashtable that maps passwords to their usernames. Now what if i want to store the Firstname and lastname of the person, in case he/she forgets the password or username? Is there a way to associate a key (Password) to multiple values(username, password, lastname)? if so, can you show me how to go about it?
    Edited by: Tonata on Apr 27, 2009 8:09 AM

    M.Murat wrote:
    Hello
    My suggestion is that you can create a map in which value is a list(for example Arraylist).
    You can store the items in that list and match that list to proper key.
    M.MuratCode smell: Object Denial+_                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Searching a Table field with multiple values using a shuttle item

    Hello All,
    I have a shuttle item whhich of course users can select multiple values:
    eg: Orange:Pear:Banana
    Now I have a table where I want to get the Crate Numbers where these fruit items reside.
    The Fruit field has multiple stored values
    eg:
    Crate Fruits
    === ====
    12487 Apple:Orange:Pear:Banana
    17653 Orange:Pear:Grapes
    12874 Apple:Banana
    13655 Grapes:Watermelon:Pineapple
    87643 Pear:Banana
    53626 Strawberries:Apple
    I would like to see a final report similiar to this
    Crate Fruit
    === ===
    12487 Orange
    12487 Pear
    12487 Banana
    17653 Orange
    17653 Pear
    12874 Banana
    87643 Pear
    87643 Banana
    I thought maybe this needs to be done using collections but I am not familiar with this function, if their is another way I would appreciate it
    Hope u can help
    Frank

    Hi Frank,
    I find that in this sort of case, it is easier to create a link table containing the individual values rather than lumping them into one column.
    so the data is stored in the 'Crate, Fruit' format, rather then the 'Crate Fruits' format.
    It is a bit more work maintaining the link table when the values are amended and populating the shuttle, but it is a 'proper' relational table then.
    Regards
    Michael

  • Read Internal Table based on Multiple Values for Key Field

    Hi Gurus,
    i have one query can you tell me how read an internal table it_kna1 for multiple values of land1 DE US IND etc.
    i had tried as below but i could not can you try and let me knwo at the earliest.
    here i want read the values with DE or US and want further prosess them.
    REPORT  YC001.
    tables kna1.
    select-options: cust for kna1-kunnr.
    data: begin of it_kna1 occurs 0,
            kunnr like kna1-kunnr,
            name1 like kna1-name1,
            land1 like kna1-land1,
            end of it_kna1.
    select kunnr name1 land1 into table it_kna1 from kna1 where kunnr in cust.
    read table it_kna1 with key land1 = ( 'DE' OR 'US' ) .
    can anybody suggest me some solution.
    Thanks,
    Jeevi.

    This should be what you need:
    REPORT ztest NO STANDARD PAGE HEADING LINE-SIZE 80 MESSAGE-ID 00.
    TABLES kna1.
    SELECT-OPTIONS: cust FOR kna1-kunnr.
    DATA: BEGIN OF it_kna1 OCCURS 0,
            kunnr LIKE kna1-kunnr,
            name1 LIKE kna1-name1,
            land1 LIKE kna1-land1,
          END OF it_kna1.
    DATA: itab_index LIKE sy-tabix.
    SELECT kunnr name1 land1
      INTO TABLE it_kna1
      FROM kna1
      WHERE kunnr IN cust.
    SORT it_kna1 BY land1.
    READ TABLE it_kna1 WITH KEY
      land1 = 'DE'
      BINARY SEARCH.
    itab_index = sy-tabix.
    WHILE sy-subrc = 0.
      itab_index = itab_index + 1.
      WRITE: /001 it_kna1-kunnr, it_kna1-land1, it_kna1-name1.
      READ TABLE it_kna1 INDEX itab_index.
      IF it_kna1-land1 <> 'DE'.
        sy-subrc = 99.
      ENDIF.
    ENDWHILE.
    SKIP 1.
    READ TABLE it_kna1 WITH KEY
      land1 = 'US'
      BINARY SEARCH.
    itab_index = sy-tabix.
    WHILE sy-subrc = 0.
      itab_index = itab_index + 1.
      WRITE: /001 it_kna1-kunnr, it_kna1-land1, it_kna1-name1.
      READ TABLE it_kna1 INDEX itab_index.
      IF it_kna1-land1 <> 'US'.
        sy-subrc = 99.
      ENDIF.
    ENDWHILE.
    Rob

  • Setting Multiple values in property set using java API

    Hello All,
    I want to set the properties of a profile in a property set using java API provided
    in package p13n. The property can have multiple values. When I try to add the
    property using ProfileManager.setProperty() method. But every time I do it this
    way, it replaces the earlier value of property and not added. This, I can achieve
    using portalTools but I want to use the API for user registration on the site.
    I hope the query is clear.
    Waiting for a response,
    Thanks in advance,
    Shrinivas

    You need to use java.util.ArrayList.
    First cast the existing value into ArrayList using getProperty method,
    change values in the ArrayList and then put them back with setProperty
    method.
    Regards,
    Michael Goldverg
    "Shrinivas Rao" <[email protected]> wrote in message
    news:3d64e7d9$[email protected]..
    >
    Hello All,
    I want to set the properties of a profile in a property set using java APIprovided
    in package p13n. The property can have multiple values. When I try to addthe
    property using ProfileManager.setProperty() method. But every time I do itthis
    way, it replaces the earlier value of property and not added. This, I canachieve
    using portalTools but I want to use the API for user registration on thesite.
    I hope the query is clear.
    Waiting for a response,
    Thanks in advance,
    Shrinivas

  • Multiple values for a Like condition

    How can I make a like condition for multiple value options,
    for example
    select b.segment1, b.segment2, b.description, c.cross_reference, c.cross_reference_type
    from inv.mtl_system_items_b b, inv.mtl_cross_references_b c
    where b.inventory_item_id = c.inventory_item_id and
          b.ORGANIZATION_ID = 136 and
          c.cross_reference like (
    '1267801228%',
    '1267801230%',
    '1500005030%',
    '1745%',
    '1874106005%',
    '2004%',
    '2004%',
    '232003000000%',
    '303681020128%',
    '3426441351%',
    '489122853014%',
    '4894230110%',
    '5383800117%',
    '5422810701%',
    '5422810711%',
    '5422810711%',
    '70986205105%',
    '70986205112%',
    '70986205122%',
    '70986205131%',
    '70986205131%',
    '70986205131%',
    '70986205142%')Edited by: user8986013 on 28-oct-2010 8:19

    One way could be to sort the String for length and then use SUBSTR with an IN-List:
    select b.segment1, b.segment2, b.description, c.cross_reference, c.cross_reference_type
    from inv.mtl_system_items_b b, inv.mtl_cross_references_b c
    where b.inventory_item_id = c.inventory_item_id and
          b.ORGANIZATION_ID = 136 and
          (substr(c.cross_reference,1,12) in (     
                               '232003000000',
                               '303681020128',
                               '489122853014')
           or                           
           substr(c.cross_reference,1,11) in (                                                           
                               '70986205105',
                               '70986205112',
                               '70986205122',
                               '70986205131',
                               '70986205142')
           or                   
           substr(c.cross_reference,1,10) in (                                                           
                               '4894230110',
                               '5383800117',
                               '5422810701',                          
                               '5422810711',
                               '3426441351',
                               '1267801228',
                               '1267801230',
                               '1500005030',
                               '1874106005')
           or                          
           substr(c.cross_reference,1,4) in (
                               '1745',
                               '2004')
          );By the way: I removed some duplicates.
    Edited by: hm on 28.10.2010 09:29

  • #MULTIPLE VALUE error in WEB I 4.1 SP2

    HI ALL
    I am getting #MULTIPLE VALUE error in few of the records in a column (assume A). Column A is formula in BEx. I am displaying data in web I based on Material division(1st column) and material group(2nd column). I tried with all : in, forall, foreach in WEB I , which doesn't sort out my issue. Can any body helpme out  here. Again, I am using BEx Query, and column A is formula in BW BEx.
    Awaiting for helpful answers.
    Regards
    swetha.

    Hi Swetha,
    use Sum([Column A])

Maybe you are looking for

  • Problems with my second monitor after upgrading to Mountain Lion

    Basically I have a Mac Pro 8-core with two video boards (2 x NVIDIA GeForce GT 120 512 MB) connected to two monitors. After upgrading to the Lion Mountain, 90% of the time when I start my MAC the second monitor doesn't show it image, keeps in full bl

  • IOS 5 beta messages won't sign in

    I have decided to use the new IOS 5 beta. From what I've seen, the brand new application i messages works on IOS 5 beta. I updated my third generation iPod touch to the new beta software on iTunes 10.3. Ounce I had finished setting up the new softwar

  • Runtime image storage best practice ?

    Hello, I have a question regarding the best place to store images that will be loaded at runtime. I understand the concept of having an assets folder within the project and keeping certain images as a part of the project itself, but what about storin

  • [ADF] One Skin, Multiple Applications

    Hi, I was wondering what the "best practice" is to have one skin for multiple applications. Ideally I'd like to be able to make a tiny change in the main skin and it changes the look and feel for many apps. Is that even possible? I'm using standalone

  • Do i need to add tld files in stuts 2.0

    Hi do i need to add tld files in stuts 2 can any one tell me here vijay