public static Keyword querySqlDatabaseSpecialist(ControlFrame frame, Keyword lastmove) {
    lastmove = lastmove;
    { Vector arguments = frame.proposition.arguments;
      Stella_Object database = Logic.argumentBoundTo((arguments.theArray)[0]);
      Stella_Object query = Logic.argumentBoundTo((arguments.theArray)[1]);

      if ((database == null) ||
          ((!Stella_Object.stringP(query)) ||
           (!Logic.testIsaP(database, RDBMS.SGT_RDBMS_SQL_DATABASE)))) {
        return (RDBMS.KWD_TERMINAL_FAILURE);
      }
      if (((Iterator)(KeyValueList.dynamicSlotValue(frame.dynamicSlots, RDBMS.SYM_STELLA_ITERATOR, null))) == null) {
        { KeyValueList bindings = RDBMS.collectQueryDatabaseSpecialistBindings(frame, 2);

          query = StringWrapper.wrapString(edu.isi.sdbc.Sdbc.instantiateSqlCmdTemplate(((StringWrapper)(query)).wrapperValue, bindings));
          query = StringWrapper.wrapString(RDBMS.sqlQueryInstantiateConstraints(((StringWrapper)(query)).wrapperValue, bindings));
          KeyValueList.setDynamicSlotValue(frame.dynamicSlots, RDBMS.SYM_STELLA_ITERATOR, edu.isi.sdbc.Connection.getResultSet(RDBMS.getConnectionFromDatabase(((LogicObject)(database))), ((StringWrapper)(query)).wrapperValue, Stella.NIL), null);
        }
      }
      return (RDBMS.bindNextDatabaseTupleToArguments(frame, 2));
    }
  }