public static Keyword bindNextDatabaseTupleToArguments(ControlFrame frame, int firstargindex) {
    { Vector arguments = frame.proposition.arguments;
      int nofoutputs = arguments.length() - firstargindex;
      Iterator iterator = ((Iterator)(KeyValueList.dynamicSlotValue(frame.dynamicSlots, RDBMS.SYM_STELLA_ITERATOR, null)));
      PatternRecord patternrecord = ((QueryIterator)(Logic.$QUERYITERATOR$.get())).currentPatternRecord;
      int ubstackoffset = patternrecord.topUnbindingStackOffset;
      boolean checkedunboundoutputsP = false;

      while (iterator.nextP()) {
        { boolean alwaysP000 = true;

          { StringWrapper output = null;
            Cons iter000 = ((Cons)(iterator.value));
            int i = Stella.NULL_INTEGER;
            int iter001 = firstargindex;
            int upperBound000 = arguments.length() - 1;

            loop001 : for (;(!(iter000 == Stella.NIL)) &&
                      (iter001 <= upperBound000); iter000 = iter000.rest, iter001 = iter001 + 1) {
              output = ((StringWrapper)(iter000.value));
              i = iter001;
              if (!RDBMS.collectionValuedConstraintP(Logic.argumentBoundTo((arguments.theArray)[i]))) {
                if (!Logic.bindArgumentToValueP((arguments.theArray)[i], RDBMS.coerceStringToPowerloomObject(StringWrapper.unwrapString(output), Logic.getDescription(Logic.logicalType((arguments.theArray)[i])), ((Module)(Stella.$MODULE$.get())), false), true)) {
                  alwaysP000 = false;
                  break loop001;
                }
              }
            }
          }
          if (alwaysP000) {
            if ((!checkedunboundoutputsP) &&
                (((Cons)(iterator.value)).length() < nofoutputs)) {
              { int i = Stella.NULL_INTEGER;
                int iter002 = ((Cons)(iterator.value)).length() + firstargindex;
                int upperBound001 = arguments.length() - 1;

                for (;iter002 <= upperBound001; iter002 = iter002 + 1) {
                  i = iter002;
                  if (Logic.argumentBoundTo((arguments.theArray)[i]) == null) {
                    return (RDBMS.KWD_TERMINAL_FAILURE);
                  }
                }
              }
            }
            checkedunboundoutputsP = true;
            return (RDBMS.KWD_CONTINUING_SUCCESS);
          }
        }
        PatternRecord.unbindVariablesBeginningAt(patternrecord, ubstackoffset + 1);
      }
      return (RDBMS.KWD_TERMINAL_FAILURE);
    }
  }