def iterateUnionRecords(tables,fieldNames)
   
      raise "'iterateUnionRecords' must be called with a block." if not block_given?   
   
      if tables and tables.is_a?(Array)
         if fieldNames and fieldNames.is_a?(Array)
            tableRecords = []
            tables.each{|table|
               if table and table.is_a?(Hash) and table["dbid"]
                  tableRecords << getAllValuesForFields( table["dbid"],
                                                                        fieldNames,
                                                                        table["query"],
                                                                        table["qid"],
                                                                        table["qname"],
                                                                        table["clist"],
                                                                        table["slist"],
                                                                        "structured",
                                                                        table["options"])
               else
                  raise "'table' must be a Hash that includes an entry for 'dbid'."
               end
            }
         else
            raise "'fieldNames' must be an Array of field names valid in all the tables."
         end
      else
         raise "'tables' must be an Array of Hashes."
      end
      usedRecords = {}
      tableRecords.each{|queryResults|
         if queryResults
            numRecords = 0
            numRecords = queryResults[fieldNames[0]].length if queryResults[fieldNames[0]]
            (0..(numRecords-1)).each{|recNum|
               recordHash = {}
               fieldNames.each{|fieldName|
                  recordHash[fieldName]=queryResults[fieldName][recNum]
               }
               if not usedRecords[recordHash.values.join]
                  usedRecords[recordHash.values.join]=true
                  yield recordHash
               end
            }
         end
      }
   end
def iterateUnionRecords(tables,fieldNames)
   
      raise "'iterateUnionRecords' must be called with a block." if not block_given?   
   
      if tables and tables.is_a?(Array)
         if fieldNames and fieldNames.is_a?(Array)
            tableRecords = []
            tables.each{|table|
               if table and table.is_a?(Hash) and table["dbid"]
                  tableRecords << getAllValuesForFields( table["dbid"],
                                                                        fieldNames,
                                                                        table["query"],
                                                                        table["qid"],
                                                                        table["qname"],
                                                                        table["clist"],
                                                                        table["slist"],
                                                                        "structured",
                                                                        table["options"])
               else
                  raise "'table' must be a Hash that includes an entry for 'dbid'."
               end
            }
         else
            raise "'fieldNames' must be an Array of field names valid in all the tables."
         end
      else
         raise "'tables' must be an Array of Hashes."
      end
      usedRecords = {}
      tableRecords.each{|queryResults|
         if queryResults
            numRecords = 0
            numRecords = queryResults[fieldNames[0]].length if queryResults[fieldNames[0]]
            (0..(numRecords-1)).each{|recNum|
               recordHash = {}
               fieldNames.each{|fieldName|
                  recordHash[fieldName]=queryResults[fieldName][recNum]
               }
               if not usedRecords[recordHash.values.join]
                  usedRecords[recordHash.values.join]=true
                  yield recordHash
               end
            }
         end
      }
   end
Get values from the same fields in two or more tables and/or queries and loop through the merged results.
 The merged records will be unique. This is similar to an SQL UNION.