MCPcopy Index your code
hub / github.com/apache/groovy / firstRow

Method firstRow

subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java:2491–2502  ·  view source on GitHub ↗

Performs the given SQL query and return the first row of the result set. Example usage: def ans = sql.firstRow("select from PERSON where firstname like 'S%'") println ans.firstname Resource handling is performed automatically where appropriate. @param sql the SQL statement @ret

(String sql)

Source from the content-addressed store, hash-verified

2489 * @throws SQLException if a database access error occurs
2490 */
2491 public GroovyRowResult firstRow(String sql) throws SQLException {
2492 List<GroovyRowResult> rows = null;
2493 try {
2494 rows = rows(sql, 1, 1, null);
2495 }
2496 //should be SQLFeatureNotSupportedException instead once we move to Java 1.6
2497 catch (SQLException featureNotSupportedException) {
2498 rows = rows(sql);
2499 }
2500 if (rows.isEmpty()) return null;
2501 return rows.get(0);
2502 }
2503
2504 /**
2505 * Performs the given SQL query and return

Callers

nothing calls this directly

Calls 7

rowsMethod · 0.95
getParametersMethod · 0.95
asSqlMethod · 0.95
singletonListMethod · 0.95
getMethod · 0.65
isEmptyMethod · 0.45
asListMethod · 0.45

Tested by

no test coverage detected