Simple convenience wrapper around the generic select call.
 Throws an exception unless the result set is empty or a single row.
 Returns nil if the result set is empty, or the row selected.
197183
def select_optional_row(statement, build_arg = nil)
    rows = select(statement, build_arg)
    raise UnexpectedQueryResult, "selected #{rows.size} rows; expected 0 or 1" if rows.size > 1
    if rows.empty? then nil else rows[0] end
  end
251988
private final TryCatchFinally tryStatement(Data data) throws TemplateException {
	if (!data.srcCode.forwardIfCurrent("try", '{') && !data.srcCode.forwardIfCurrent("try ") && !data.srcCode.forwardIfCurrent("try", '/')) return null;
	data.srcCode.previous();

	Body body = new BodyBase(data.factory);
	TryCatchFinally tryCatchFinally = new TryCatchFinally(data.factory, body, data.srcCode.getPosition(), null);

	Body prior = data.setParent(body);
	statement(data, body, CTX_TRY);
	data.setParent(prior);
	comments(data);

	// catches
	short catchCount = 0;
	while (data.srcCode.forwardIfCurrent("catch", '(')) {
	    catchCount++;
	    comments(data);

	    // type
	    int pos = data.srcCode.getPos();
	    Position line = data.srcCode.getPosition();
	    Expression name = null, type = null;

	    StringBuffer sbType = new StringBuffer();
	    String id;
	    while (true) {
		id = identifier(data, false);
		if (id == null) break;
		sbType.append(id);
		data.srcCode.removeSpace();
		if (!data.srcCode.forwardIfCurrent('.')) break;
		sbType.append('.');
		data.srcCode.removeSpace();
	    }

	    if (sbType.length() == 0) {
		type = string(data);
		if (type == null) throw new TemplateException(data.srcCode, "a catch statement must begin with the throwing type (query, application ...).");
	    }
	    else {
		type = data.factory.createLitString(sbType.toString());
	    }

	    // name = expression();
	    comments(data);

	    // name
	    if (!data.srcCode.isCurrent(')')) {
		name = expression(data);
	    }
	    else {
		data.srcCode.setPos(pos);
		name = expression(data);
		type = data.factory.createLitString("any");
	    }
	    comments(data);

	    Body b = new BodyBase(data.factory);
	    try {
		tryCatchFinally.addCatch(type, name, b, line);
	    }
	    catch (TransformerException e) {
		throw new TemplateException(data.srcCode, e.getMessage());
	    }
	    comments(data);

	    if (!data.srcCode.forwardIfCurrent(')')) throw new TemplateException(data.srcCode, "invalid catch statement, missing closing )");

	    Body _prior = data.setParent(b);
	    statement(data, b, CTX_CATCH);
	    data.setParent(_prior);
	    comments(data);
	}

	// finally
	if (finallyStatement(data, tryCatchFinally)) {
	    comments(data);
	}
	else if (catchCount == 0) throw new TemplateException(data.srcCode, "a try statement must have at least one catch statement");

	// if(body.isEmpty()) return null;
	tryCatchFinally.setEnd(data.srcCode.getPosition());
	return tryCatchFinally;
    }
671914
private void validateSelectQuery(final String selectQuery) {
        final SimpleDBParser parser = new SimpleDBParser(selectQuery);
        try {
            parser.selectQuery();
        } catch (Exception e) {
            throw new InvalidSimpleDBQueryException("The following query is an invalid SimpleDB query: " + selectQuery,
                    e);
        }
    }
1289811
public boolean hasNextThrow() throws SQLException {
		if (closed) {
			return false;
		}
		if (alreadyMoved) {
			// we do this so multiple hasNext() calls can be made, result would be true or closed is true
			return true;
		}
		boolean result;
		if (first) {
			first = false;
			result = results.first();
		} else {
			result = results.next();
		}
		if (!result) {
			IOUtils.closeThrowSqlException(this, "iterator");
		}
		alreadyMoved = true;
		return result;
	}
996572
private void checkIndex(int parameterIndex, boolean fetchingData) throws SQLException {
    if (!isFunction) {
      throw new PSQLException(
          GT.tr(
              "A CallableStatement was declared, but no call to registerOutParameter(1, <some type>) was made."),
          PSQLState.STATEMENT_NOT_ALLOWED_IN_FUNCTION_CALL);
    }

    if (fetchingData) {
      if (!returnTypeSet) {
        throw new PSQLException(GT.tr("No function outputs were registered."),
            PSQLState.OBJECT_NOT_IN_STATE);
      }

      if (callResult == null) {
        throw new PSQLException(
            GT.tr("Results cannot be retrieved from a CallableStatement before it is executed."),
            PSQLState.NO_DATA);
      }

      lastIndex = parameterIndex;
    }
  }
617396
public Integer getSelectedRow() {
        final Object result = getStateHelper().eval(PropertyKeys.selectedRow);
        if (result == null) {
            return null;
        }
        return Integer.valueOf(result.toString());
    }
1215295
@SuppressWarnings("unchecked")
    protected <T> T get(final Select _select)
        throws EFapsException
    {
        Object ret = null;
        final List<Boolean> accessList = access(_select);
        final Object obj = _select.getCurrent();
        if (obj instanceof List) {
            final Iterator<Boolean> iter = accessList.iterator();
            ret = ((List<?>) obj).stream()
                .map(ele -> iter.hasNext() && iter.next() ? ele : null)
                .collect(Collectors.toList());
            ret = agregate(_select, (List<Object>) ret);
        } else if (accessList.size() == 1 && accessList.get(0)) {
            ret = obj;
        }
        return (T) ret;
    }
228792
public Object firstRow() throws SQLException {
        List rows = rows();
        if (rows.isEmpty()) return null;
        return (rows.get(0));
    }
1230361
public ResultSet executeQuery(String sql) throws SQLException {
    if (executeInternal(sql, fetchSize, Statement.NO_GENERATED_KEYS)) {
      return results.getResultSet();
    }
    return SelectResultSet.createEmptyResultSet();
  }
67571
def ask_select prompt="Enter selection pattern: "
      ret = get_string prompt
      return if ret.nil? || ret ==  ""
      indices = get_matching_indices ret
      #$log.debug "listselectionmodel: ask_select got matches#{@indices} "
      return if indices.nil? || indices.empty?
      indices.each { |e|
        # will not work if single select !! FIXME
        add_row_selection_interval e,e
      }
    end
1270251
protected int[] getRowCounts(Vector inTable,
                                 Vector inSchema) throws Exception {

        if (!displayRowCounts) {
            return (null);
        }

        String rowCountSelect = "SELECT COUNT(*) FROM ";
        int[]  counts;
        String name;

        counts = new int[inTable.size()];

        try {
            Statement select = rowConn.createStatement();

            for (int i = 0; i < inTable.size(); i++) {
                try {
                    String schemaPart = (String) inSchema.elementAt(i);

                    schemaPart = schemaPart == null ? ""
                                                    : (schemaPart + '.');
                    name       = schemaPart + (String) inTable.elementAt(i);

                    ResultSet resultSet = select.executeQuery(rowCountSelect
                        + name);

                    while (resultSet.next()) {
                        counts[i] = resultSet.getInt(1);
                    }
                } catch (Exception e) {
                    System.err.println("Unable to get row count for table "
                                       + inSchema.elementAt(i) + '.'
                                       + inTable.elementAt(i)
                                       + ".  Using value '0': " + e);
                }
            }
        } catch (Exception e) {
            CommonSwing.errorMessage(e);
        }

        return (counts);
    }
1149846
public boolean next() throws SQLException {
        boolean result = queryResult.next();
        orderValues = result ? getOrderValues() : Collections.<Comparable<?>>emptyList();
        return result;
    }
1290975
def iselect(select, tag, namespaces=None, limit=0, flags=0, **kwargs):
    """"""

    for el in compile(select, namespaces, flags, **kwargs).iselect(tag, limit):
        yield el
492210
function select($column0=null, $_=null){
        $obj = new SelectRule(new Context($this->connection));
        if($column0 == null){
            $args = ['*'];
        }elseif(is_array($column0)){
            $args = $column0;
        }else{
            $args = func_get_args();
        }
        foreach ($args as &$arg){
            $arg = DB::wrap($arg);
            if($arg == '*'){
                continue;
            }
        }
        return $obj->select(implode(',', $args));
    }
625447
def fetchone(self):
        
        self._assert_valid_result_set()
        result = self.result_set.fetch_row()
        if len(result) == 0:
            return None
        else:
            return result
551129
public boolean execute() throws SQLException {
        boolean isExceptionThrown = ExecutorExceptionHandler.isExceptionThrown();
        SQLExecuteCallback<Boolean> executeCallback = SQLExecuteCallbackFactory.getPreparedSQLExecuteCallback(getDatabaseType(), isExceptionThrown);
        List<Boolean> result = executeCallback(executeCallback);
        if (null == result || result.isEmpty() || null == result.get(0)) {
            return false;
        }
        return result.get(0);
    }
1222400
public T fetchSingleOrNull() throws InstantiationException, IllegalAccessException, SQLException {
        if (!finished) {
            T result = primitive ? fetchSinglePrimitiveInternal() : fetchSingleInternal();
            next();
            return result;
        } else {
            return null;
        }
    }