You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Janet Li <li...@yahoo.com> on 2006/04/19 20:03:55 UTC

building query using values from 2 lists

Hi
   
  I have two lists that I need to iterate in order in build my SQL statement.  I would like to know how I would go about in doing that using iBatis.
   
  I have 2 list:
  partitionList=[01, 02];
  IDList=[10001, 10002];
   
  Basically it should look like this:
  SELECT DISTINCT NVL(attr_display_name, attr_column_name) as NAME, attr_display_order as ORDER_VALUE"
        + " FROM md_attr_list_"
          + partitionList[0]
        + " where zeid = "
        + IDList[0] + " and resultset_id = 1";
  union
  SELECT DISTINCT NVL(attr_display_name, attr_column_name) as NAME, attr_display_order as ORDER_VALUE"
        + " FROM  md_attr_list_"
        + partitionList[1]
        + " where zeid = "
        + IDList[1] + " and resultset_id = 1";
   
  etc...
   
  I should be using the iterate tag but how can I iterate over 2 lists?  The list will always be the same size.  I believe I can do this using by iterating a list of beans which contains a value for each of the list.  However, I don't want to create 30 beans if I have 30 items in my lists.


   
  Thanks.

		
---------------------------------
New Yahoo! Messenger with Voice. Call regular phones from your PC and save big.