Returns handler that detects statement matching given pattern(s) as query.
Returns handler that detects statement matching given pattern(s) as query.
import acolyte.jdbc.AcolyteDSL.handleStatement // Created handle will detect as query statements // either starting with 'SELECT ' or containing 'EXEC proc'. handleStatement.withQueryDetection("^SELECT ", "EXEC proc")
Returns handler that delegates query execution to |h| function.
Returns handler that delegates query execution to |h| function. Given function will be used only if executed statement is detected as a query by withQueryDetection.
import acolyte.jdbc.QueryExecution import acolyte.jdbc.AcolyteDSL.handleStatement handleStatement withQueryHandler { e: QueryExecution => aQueryResult } // With pattern matching ... import acolyte.jdbc.ParameterVal handleStatement withQueryHandler { _ match { case QueryExecution("SELECT * FROM Test WHERE id = ?", ParameterVal(1) :: Nil) => aQueryResult case _ => otherResult } }
Returns handler that delegates update execution to |h| function.
Returns handler that delegates update execution to |h| function. Given function will be used only if executed statement is not detected as a query by withQueryDetection.
import acolyte.jdbc.UpdateExecution import acolyte.jdbc.AcolyteDSL.handleStatement handleStatement withUpdateHandler { e: UpdateExecution => aQueryResult } // With pattern matching ... import acolyte.jdbc.ParameterVal handleStatement withUpdateHandler { _ match { case UpdateExecution("INSERT INTO Country (code, name) VALUES (?, ?)", ParameterVal(code) :: ParameterVal(name) :: Nil) => 1 /* update count */ case _ => otherResult } }