Converts this query result as T
, using parser.
Converts this query result as T
, using parser.
the result parser
#asTry
Converts this query result as T
, using parser.
Converts this query result as T
, using parser.
the result parser
the column aliaser
Executes this SQL statement.
Executes this SQL statement.
true if resultset was returned from execution (statement is query), or false if it executed update.
val res: Boolean = SQL"""INSERT INTO Test(a, b) VALUES(\${"A"}, \${"B"}""".execute()
Executes this SQL as an insert statement.
Executes this SQL as an insert statement.
Parser for generated key (default: scalar long)
Parsed generated keys
import anorm.SqlParser.scalar val keys1 = SQL("INSERT INTO Test(x) VALUES ({x})"). on("x" -> "y").executeInsert() val keys2 = SQL("INSERT INTO Test(x) VALUES ({x})"). on("x" -> "y").executeInsert(scalar[String].singleOpt) // ... generated string key
Executes this SQL as an insert statement.
Executes this SQL as an insert statement.
the first (mandatory) column name to consider from the generated keys
the other (possibly none) column name(s) from the generated keys
the parser for generated key (default: scalar long)
Parsed generated keys
import anorm.SqlParser.scalar val keys1 = SQL("INSERT INTO Test(x) VALUES ({x})"). on("x" -> "y").executeInsert1("generatedCol", "colB")() val keys2 = SQL("INSERT INTO Test(x) VALUES ({x})"). on("x" -> "y").executeInsert1("generatedCol")(scalar[String].singleOpt) // ... generated string key
Executes this SQL as an insert statement.
Executes this SQL as an insert statement.
the first (mandatory) column name to consider from the generated keys
the other (possibly none) column name(s) from the generated keys
the parser for generated key (default: scalar long)
the column aliaser
Parsed generated keys
import anorm.SqlParser.scalar val keys1 = SQL("INSERT INTO Test(x) VALUES ({x})"). on("x" -> "y").executeInsert1("generatedCol", "colB")() val keys2 = SQL("INSERT INTO Test(x) VALUES ({x})"). on("x" -> "y").executeInsert1("generatedCol")(scalar[String].singleOpt) // ... generated string key
Executes this SQL query, and returns its result.
Executes this SQL query, and returns its result.
implicit val conn: Connection = openConnection val res: SqlQueryResult = SQL("SELECT text_col FROM table WHERE id = {code}"). on("code" -> code).executeQuery() // Check execution context; e.g. res.statementWarning val str = res as scalar[String].single // going with row parsing
Executes this SQL as an update statement.
Executes this SQL as an update statement.
Count of updated row(s)
Fetch size
Aggregates over all rows using the specified operator.
Aggregates over all rows using the specified operator.
the start value
the column aliaser
Aggregate operator
Either list of failures at left, or aggregated value
#withResult
#foldWhile
Aggregates over part of or the while row stream, using the specified operator.
Aggregates over part of or the while row stream, using the specified operator.
the start value
the column aliaser
Aggregate operator. Returns aggregated value along with true if aggregation must process next value, or false to stop with current value.
Either list of failures at left, or aggregated value
#withResult
Returns query prepared with named parameters.
Returns query prepared with named parameters.
import anorm.toParameterValue val baseSql = SQL("SELECT * FROM table WHERE id = {id}") // one named param val preparedSql = baseSql.withParams("id" -> "value")
Returns query prepared with parameters using initial order of placeholder in statement.
Returns query prepared with parameters using initial order of placeholder in statement.
import anorm.toParameterValue val baseSql = SQL("SELECT * FROM table WHERE name = {name} AND lang = {lang}") val preparedSql = baseSql.onParams("1st", "2nd") // 1st param = name, 2nd param = lang
Executes this statement as query (see executeQuery) and returns result.
Executes this statement as query (see executeQuery) and returns result.
ResultSet is initialized on first row (JDBC degraded)
ResultSet is initialized on first row (JDBC degraded)
Returns this query with the fetch suze updated to the row count
.
Returns this query with the fetch suze updated to the row count
.
Returns a copy with updated timeout.
Processes all or some rows from current result.
Processes all or some rows from current result.
Operation applied with row cursor
@annotation.tailrec def go(c: Option[Cursor], l: List[Row]): List[Row] = c match { case Some(cursor) => go(cursor.next, l :+ cursor.row) case _ => l } val l: Either[List[Throwable], List[Row]] = SQL"SELECT * FROM Test".withResult(go)
Processes all or some rows from current result.
Processes all or some rows from current result.
Operation applied with row cursor
Returns a copy with updated flag.
Aggregates over all rows using the specified operator.
Aggregates over all rows using the specified operator.
the start value
Aggregate operator
Either list of failures at left, or aggregated value
(Since version 2.5.1) Use fold
with empty ColumnAliaser
#withResult
#foldWhile
Aggregates over part of or the while row stream, using the specified operator.
Aggregates over part of or the while row stream, using the specified operator.
the start value
Aggregate operator. Returns aggregated value along with true if aggregation must process next value, or false to stop with current value.
Either list of failures at left, or aggregated value
(Since version 2.5.1) Use foldWhile
with empty ColumnAliaser
#withResult
Prepares query with given row parser.
Prepares query with given row parser.
import anorm.{ SQL, SqlParser } val res: Int = SQL("SELECT 1").using(SqlParser.scalar[Int]).single // Equivalent to: SQL("SELECT 1").as(SqlParser.scalar[Int].single)
(Since version 2.5.1) Use as
Simple/plain SQL.