public static Keyword retrieveNextDbQuerySolution(ControlFrame frame, Keyword lastmove) {
    { Vector arguments = frame.proposition.arguments;
      Iterator iterator = ((Iterator)(KeyValueList.dynamicSlotValue(frame.dynamicSlots, RDBMS.SYM_STELLA_ITERATOR, null)));

      lastmove = lastmove;
      if (!(iterator != null)) {
        return (RDBMS.KWD_FAILURE);
      }
      if (iterator.firstIterationP) {
        if (!(iterator.nextP())) {
          return (RDBMS.KWD_FAILURE);
        }
        iterator.firstIterationP = false;
      }
      loop000 : for (;;) {
        { boolean nonullsP = true;
          Cons result = Stella.NIL;
          Stella_Object binding = null;

          { Stella_Object col = null;
            Cons iter000 = ((Cons)(iterator.value));
            Stella_Object arg = null;
            Vector vector000 = arguments;
            int index000 = 0;
            int length000 = vector000.length();
            Cons collect000 = null;

            for (;(!(iter000 == Stella.NIL)) &&
                      (index000 < length000); iter000 = iter000.rest, index000 = index000 + 1) {
              col = iter000.value;
              arg = (vector000.theArray)[index000];
              binding = Logic.argumentBoundTo(arg);
              if (col == null) {
                nonullsP = false;
              }
              else if (binding != null) {
                col = binding;
              }
              if (collect000 == null) {
                {
                  collect000 = Cons.cons(col, Stella.NIL);
                  if (result == Stella.NIL) {
                    result = collect000;
                  }
                  else {
                    Cons.addConsToEndOfConsList(result, collect000);
                  }
                }
              }
              else {
                {
                  collect000.rest = Cons.cons(col, Stella.NIL);
                  collect000 = collect000.rest;
                }
              }
            }
          }
          if (((((QueryIterator)(Logic.$QUERYITERATOR$.get())) != null) &&
              (((QueryIterator)(Logic.$QUERYITERATOR$.get())).partialMatchStrategy != null)) ||
              nonullsP) {
            if (Logic.bindVectorOfArgumentsToValuesP(arguments, result)) {
              break loop000;
            }
          }
          if (!(iterator.nextP())) {
            return (RDBMS.KWD_FAILURE);
          }
        }
      }
      if (iterator.nextP()) {
        return (RDBMS.KWD_CONTINUING_SUCCESS);
      }
      else {
        {
          ControlFrame.setFrameTruthValue(frame, Logic.TRUE_TRUTH_VALUE);
          return (RDBMS.KWD_FINAL_SUCCESS);
        }
      }
    }
  }