Execute the clause and return the generated keys as a ResultSet

@return result set with generated keys
328316
public ResultSet executeWithKeys() {
        context = startContext(connection(), metadata, entity);
        try {
            PreparedStatement stmt = null;
            if (batches.isEmpty()) {
                stmt = createStatement(true);
                listeners.notifyInsert(entity, metadata, columns, values, subQuery);

                listeners.preExecute(context);
                stmt.executeUpdate();
                listeners.executed(context);
            } else if (batchToBulk) {
                stmt = createStatement(true);
                listeners.notifyInserts(entity, metadata, batches);

                listeners.preExecute(context);
                stmt.executeUpdate();
                listeners.executed(context);
            } else {
                Collection<PreparedStatement> stmts = createStatements(true);
                if (stmts != null && stmts.size() > 1) {
                    throw new IllegalStateException("executeWithKeys called with batch statement and multiple SQL strings");
                }
                stmt = stmts.iterator().next();
                listeners.notifyInserts(entity, metadata, batches);

                listeners.preExecute(context);
                stmt.executeBatch();
                listeners.executed(context);
            }

            final Statement stmt2 = stmt;
            ResultSet rs = stmt.getGeneratedKeys();
            return new ResultSetAdapter(rs) {
                @Override
                public void close() throws SQLException {
                    try {
                        super.close();
                    } finally {
                        stmt2.close();
                        reset();
                        endContext(context);
                    }
                }
            };
        } catch (SQLException e) {
            onException(context, e);
            reset();
            endContext(context);
            throw configuration.translate(queryString, constants, e);
        }
    }
33930
public function getResults()
	{
		if (!isset($this->resultset))
		{
			$this->run();
		}

		$documents = array();
		foreach ($this->resultset as $document)
		{
			array_push($documents, $document);
		}

		foreach ($documents as &$document)
		{
			$document = $document->getFields();
		}

		return $documents;
	}
1309938
public function all()
	{
		//build the select query
		$sql = $this->buildSelect();

		//set the value of the query string
		$this->query_string = $sql;

		//set the query excecution start time
		$query_start_time = microtime(true);

		//execute the sql query
		$result = $this->connector->execute($sql);

		//set the query excecution end time
		$query_stop_time = microtime(true);

		//get the query_excecution
		$query_excec_time = $query_stop_time - $query_start_time;


		//put this in try...catch block for better error handling
		try{

			//check if the query return an error and throw exception
			if ( $result === false ) 
			{
				//get the erro message
				$error = $this->connector->lastError();

				//throw exception
				throw new MySQLException(get_class(new MySQLException) . ' ' .$this->connector->lastError() . '<span class="query-string"> (' . $sql . ') </span>');

			}
			
		}

		//diplay error message
		catch(MySQLException $MySQLExceptionObject){

			//display error message
			$MySQLExceptionObject->errorShow();

		}


		//define container rows() array
		$result_array = array();

		//loop through resultset setting the values of arrays and objects
		while ($row = $result->fetch_array(MYSQLI_ASSOC)) {

			$result_array[] = $row;

		}

		//get the response object instance
		$this->responseObject
			->setQueryString($this->query_string)
			->setQueryTime($query_excec_time)
			->setFieldCount($result->field_count)
			->setNumRows($result->num_rows)
			->setQueryFields($result->fetch_fields())
			->setResultArray($result_array);

		//return the full response object
		return $this->responseObject;
	}
188423
public function executeQuery(): IResultSet {
        
        if (!strlen($this->sql) > 0) {
            throw new \Exception('Error sentencia sql no valida');
        }
        
        $temp = $this->conect->query($this->sql);
        $this->sql = "";
        
        if ($temp == null) {
            throw new \Exception('Error no se pudo encontrar nada en la base de datos');
        }
       
        return new ResultSetMYSQL($temp);
    }
311691
public function getRows()
    {
        $rows = [];
        $wheres = $this->queryBuilder->wheres ?: [];

        foreach ($wheres as $where) {

            // Skip unsupported clauses
            if (!isset($where['column'])) {
                continue;
            }

            // If it doesn't contain the table name assume it's the "FROM" table
            if (strpos($where['column'], '.') === false) {
                $where['column'] = implode('.', [$this->queryBuilder->from, $where['column']]);
            }

            list($table, $column) = $this->splitTableAndColumn($where['column']);

            // Make sure that the where clause applies for the primary key column
            if ($column !== self::PRIMARY_KEY_COLUMN) {
                continue;
            }

            // Initialize a set for the current table
            if (!isset($rows[$table])) {
                $rows[$table] = [];
            }

            // Add the rows to the current table set
            if ($where['type'] === 'Basic') {
                if ($where['operator'] === '=' && is_numeric($where['value'])) {
                    $rows[$table][] = $where['value'];
                }
            }
            else if ($where['type'] === 'In') {
                $rows[$table] += $where['values'];
            }
        }

        return $rows;
    }
64281
def execute_sql(self, query):
        
        c = self.con.cursor()
        c.execute(query)
        result = c.fetchall()
        return result
50616
private QueryObservable executeQuery(QueryBuilder queryBuilder) {

    // Raw query properties as default
    String sql = queryBuilder.rawStatement;
    Iterable<String> affectedTables = queryBuilder.rawStatementAffectedTables;

    // If SqlFinishedStatement is set then use that one
    if (queryBuilder.statement != null) {

      SqlCompileable.CompileableStatement compileableStatement =
          queryBuilder.statement.asCompileableStatement();

      sql = compileableStatement.sql;
      affectedTables = compileableStatement.tables;
    }

    // Check for auto update
    if (!queryBuilder.autoUpdate || affectedTables == null) {
      affectedTables = Collections.emptySet();
    }

    return db.createQuery(affectedTables, sql, queryBuilder.args);
  }
752335
private String buildQuery() {
        fetchKeys();

        List<String> columns = getSelectColumns();
        String selectColumnList = columns.size() == 0 ? "*" : makeColumnList(columns);
        String partitionKeyList = makeColumnList(partitionKeys);

        return String.format("SELECT %s FROM %s.%s WHERE token(%s)>? AND token(%s)<=?" + getAdditionalWhereClauses(),
                selectColumnList, quote(keyspace), quote(cfName), partitionKeyList, partitionKeyList);
    }
10581
@Override
	public ResultSet doQuery(final SqlContext sqlContext, final PreparedStatement preparedStatement,
			final ResultSet resultSet) {
		LOG.debug("SQL:{} executed.", sqlContext.getSqlName());
		return resultSet;
	}
691573
@Nullable
    public T query() throws SQLException {
        try (ResultSet r = executeQuery()) {
            if (r.next()) {
                return resultMapper.map(r);
            }
            return null;
        }
    }
5915
public QueryResults execute() throws JspCoreException, SQLException {

        Connection conn = null;
        Statement stmt = null;
        ResultSet rs = null;
        ;
        QueryResults qs = null;
        // verify all parameters
        verify();

        // invoke the compute method of QueryResults passing it the SQL resultset
        // the QueryResults will get all the data from the result set and cache it in
        // its private datastructures
        try {
            conn = getJdbcConnection();
            //conn = DriverManager.getConnection(url,user,passwd);
            stmt = conn.createStatement();
            int mrows = getMaxRows();
            if (mrows > 0)
                stmt.setMaxRows(mrows);
            rs = stmt.executeQuery(getQueryString());
            qs = new QueryResults();
            qs.compute(rs);
        }
        catch (SQLException e) {
            //com.ibm.ws.ffdc.FFDCFilter.processException(e, "com.ibm.ws.webcontainer.jsp.tsx.db.Query.execute", "73", this);
            throw e;
        }
        finally { // always free up database resources
            if (rs != null)
                rs.close();
            if (stmt != null)
                stmt.close();
            if (conn != null)
                conn.close();
        }
        setResults(qs);
        return qs;
    }
650934
protected function GetResultSetBaseQuery()
    {
        static $sBaseQuery = null;
        if (is_null($sBaseQuery)) {
            $sQuery = $this->oItemListFilteredByOtherItems->GetActiveQuery();
            $sTmpQuery = mb_strtoupper($sQuery);
            $sTmpQuery = str_replace("\n", ' ', $sTmpQuery);
            $iFromPos = strpos($sTmpQuery, ' FROM ');
            $sBaseQuery = 'SELECT DISTINCT `shop_article`.`id` '.substr($sQuery, $iFromPos);
            //        $sBaseQuery = "`_tmp_category_article`";
            $sBaseQuery = $this->getQueryModifierOrderByService()->getQueryWithoutOrderBy($sBaseQuery);
        }

        return $sBaseQuery;
    }
371786
@Override
	public ResultSet resultSet() {
		try {
			return agent().query(context());
		} catch (SQLException e) {
			throw new UroborosqlSQLException(e);
		}
	}
649908
protected void iterateResult(ResultSet resSet, QueryResultTO resultTO, StatementTO statementTO) {
		
		try {
			if (resSet != null && !resSet.isClosed()) {
	    		ResultSetMetaData metaData = resSet.getMetaData();
			    int cols = metaData.getColumnCount();
			    Map<Integer, Integer> type = new HashMap<Integer, Integer>();
			    
			    List<String> columnsNames = new ArrayList<>();
			    
			    for (int i = 1; i < (cols+1); i++)
			    {
			    	String colName = metaData.getColumnName(i);
			    	columnsNames.add(colName);
			    	type.put(i, metaData.getColumnType(i));
			    }
			   
			    List<List<String>> tableResult = new ArrayList<>();
			    String clobEncoding = statementTO.getClobEncoding() != null ? statementTO.getClobEncoding() : DEFAULT_CLOB_ENCODING;
		        while (resSet.next())
			    {
		        	List<String> row = new ArrayList<>();
		        	for (int i = 1; i < (cols+1); i++)
		    	    {
		            	if (type.get(i) != null && type.get(i) == Types.BLOB) {
		            		if (statementTO.isShowBlobs()) {
		            			row.add(String.valueOf(new String(resSet.getBytes(i))));
			                } else {
			                	row.add(String.valueOf(resSet.getObject(i)));
			                }
		            	} else if (type.get(i) != null && type.get(i) == Types.CLOB) {
		            		if (statementTO.isShowClobs()) {
		            			row.add(getClobString(resSet.getClob(i), clobEncoding ));
		            		} else {
		            			row.add("CLOB content");
		            		}
		            	} else {
		            		row.add(String.valueOf(resSet.getObject(i)));
		            	}
		    	    }
		        	tableResult.add(row);
			    }
		        
		        resultTO.setSqlWarnings(null != resSet.getWarnings() ? resSet.getWarnings().toString() : null);
		        
		        resultTO.setAffectedRows(tableResult.size());
		        resultTO.setColumnsNames(columnsNames);
		        resultTO.setTableResult(tableResult);
	    	} else {
	    		resultTO.setSqlWarnings("resultSet was " + (null != resSet ? "closed already" : "null"));
	    	}
	        resultTO.setSelect(true);
	        
		} catch (Exception e) {
			resultTO.setExceptionMessage(e.getMessage());
			resultTO.setExceptionCause(null != e.getCause() ? e.getCause().toString() : null);
			resultTO.setExceptionTrace(printException(e));
		}
	}
1269700
public Collector<T> getResults(Connection conn, DataObject object, Collector<T> collector) throws Exception {
        return executeSelect(conn, object, new ResultSetMapper<Collector<T>>(collector));
    }
1200437
final DataSet executeQuery(CallInfo callInfo, boolean takeSnapshot) {
    DataSet data = new DataSet(this);
    return db.access(callInfo, () -> {
      try (WrappedStatement ws = db.compile(getSQLForQuery())) {
        proceedWithQuery(ws.getStatement(), data);
        if (takeSnapshot) {
          setSnapshot(data);
          db.logSnapshot(callInfo, data);
        } else {
          db.logQuery(callInfo, data);
        }
      }
      return data;
    });
  }
436348
@Override
	public ResultSet doQuery(final SqlContext sqlContext, final PreparedStatement preparedStatement,
			final ResultSet resultSet) {
		try {
			if (resultSet.getType() == ResultSet.TYPE_FORWARD_ONLY) {
				LOG.warn("ResultSet type is TYPE_FORWARD_ONLY. DumpResultSqlFilter use ResultSet#beforeFirst(). Please Set TYPE_SCROLL_INSENSITIVE or TYPE_SCROLL_SENSITIVE.");
			}
			StringBuilder builder = displayResult(resultSet);
			LOG.info(builder.toString());
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return resultSet;
	}