blob: 447807da2a1d1af1d16e0923e5f449d43284c048 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// $Id:Transaction.scala 6853 2006-03-20 16:58:47 +0100 (Mon, 20 Mar 2006) dubochet $
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);
}
}
|