Executes this SQL statement as query, returns result as Row stream.
Executes this SQL statement as query, returns result as Row stream.
Executes this statement as query and convert result as T
, using parser.
Executes this statement as query and convert 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
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)
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
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.3.0) Use getFilledStatement or executeQuery
Simple/plain SQL.