Converts this query result as T
, using parser.
Converts this query result as T
, using parser.
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 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)
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
#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
#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)
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)
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)
Returns a copy with updated flag.
Executes this SQL statement as query, returns result as Row stream.
Executes this SQL statement as query, returns result as Row stream.
(Since version 2.4) Use fold, foldWhile or withResult instead, which manages resources and memory
(Since version 2.3.6) Use preparedStatement
Applies current parser with optionnal list of rows (0..n).
Applies current parser with optionnal list of rows (0..n).
(Since version 2.3.5) Use SQL("...").as(parser.*)
Applies current parser to exactly on row.
Applies current parser to exactly on row.
(Since version 2.3.5) Use SQL("...").as(parser.single)
Applies current parser to one optional row.
Applies current parser to one optional row.
(Since version 2.3.5) Use SQL("...").as(parser.singleOpt)
Simple/plain SQL.