summaryrefslogtreecommitdiff
path: root/src/library/scala/dbc/statement/Transaction.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/library/scala/dbc/statement/Transaction.scala')
-rw-r--r--src/library/scala/dbc/statement/Transaction.scala51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/library/scala/dbc/statement/Transaction.scala b/src/library/scala/dbc/statement/Transaction.scala
new file mode 100644
index 0000000000..b87c0ccc35
--- /dev/null
+++ b/src/library/scala/dbc/statement/Transaction.scala
@@ -0,0 +1,51 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2003-2005, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+package scala.dbc.statement;
+
+/** A statement that changes the status of the database. */
+case class Transaction [ResultType] (
+ transactionBody: (scala.dbc.Database=>ResultType),
+ accessMode: Option[AccessMode],
+ isolationLevel: Option[IsolationLevel]
+) extends Statement {
+
+ /** A SQL-99 compliant string representation of the statement. */
+ def sqlStartString: String = (
+ "START TRANSACTION" +
+ (Pair(accessMode,isolationLevel) match {
+ case Pair(None,None) => ""
+ case Pair(Some(am),None) => " " + am.sqlString
+ case Pair(None,Some(il)) => " " + il.sqlString
+ case Pair(Some(am),Some(il)) => " " + am.sqlString + ", " + il.sqlString
+ })
+ );
+
+ def sqlCommitString: String = {
+ "COMMIT"
+ }
+
+ def sqlAbortString: String = {
+ "ROLLBACK"
+ }
+
+ //def transactionBody: (()=>Unit);
+
+ //def accessMode: Option[AccessMode];
+
+ //def isolationLevel: Option[IsolationLevel];
+
+ def execute (database: scala.dbc.Database): scala.dbc.result.Status[ResultType] = {
+ database.executeStatement(this);
+ }
+
+ def execute (database: scala.dbc.Database, debug: Boolean): scala.dbc.result.Status[ResultType] = {
+ database.executeStatement(this,debug);
+ }
+
+}