Debian Codegraph @

doc/programmers-guide/transactions.html

raw
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2 <HTML
3 ><HEAD
4 ><TITLE
5 >Transactions</TITLE
6 ><META
7 NAME="GENERATOR"
8 CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
9 REL="HOME"
10 TITLE="Database Independent Abstraction Layer for C"
11 HREF="index.html"><LINK
12 REL="UP"
13 TITLE="Transactions and Savepoints"
14 HREF="transactions-savepoints.html"><LINK
15 REL="PREVIOUS"
16 TITLE="Transactions and Savepoints"
17 HREF="transactions-savepoints.html"><LINK
18 REL="NEXT"
19 TITLE="Savepoints"
20 HREF="savepoints.html"></HEAD
21 ><BODY
22 CLASS="SECT1"
23 BGCOLOR="#FFFFFF"
24 TEXT="#000000"
25 LINK="#0000FF"
26 VLINK="#840084"
27 ALINK="#0000FF"
28 ><DIV
29 CLASS="NAVHEADER"
30 ><TABLE
31 SUMMARY="Header navigation table"
32 WIDTH="100%"
33 BORDER="0"
34 CELLPADDING="0"
35 CELLSPACING="0"
36 ><TR
37 ><TH
38 COLSPAN="3"
39 ALIGN="center"
40 >Database Independent Abstraction Layer for C: libdbi Programmer's Guide</TH
41 ></TR
42 ><TR
43 ><TD
44 WIDTH="10%"
45 ALIGN="left"
46 VALIGN="bottom"
47 ><A
48 HREF="transactions-savepoints.html"
49 ACCESSKEY="P"
50 >Prev</A
51 ></TD
52 ><TD
53 WIDTH="80%"
54 ALIGN="center"
55 VALIGN="bottom"
56 >Chapter 5. Transactions and Savepoints</TD
57 ><TD
58 WIDTH="10%"
59 ALIGN="right"
60 VALIGN="bottom"
61 ><A
62 HREF="savepoints.html"
63 ACCESSKEY="N"
64 >Next</A
65 ></TD
66 ></TR
67 ></TABLE
68 ><HR
69 ALIGN="LEFT"
70 WIDTH="100%"></DIV
71 ><DIV
72 CLASS="SECT1"
73 ><H1
74 CLASS="SECT1"
75 ><A
76 NAME="TRANSACTIONS"
77 >5.1. Transactions</A
78 ></H1
79 ><P
80 >To find out at runtime whether or not the driver associated with the current connection supports transactions, use the function <A
81 HREF="reference-conn.html#DBI-CONN-CAP-GET"
82 >dbi_conn_cap_get</A
83 > to query if the "transaction_support" capability is nonzero. Drivers should throw an error if transaction-related functions are called although the database engine does not support them. If a database engine supports both transaction-safe and non-transaction safe table types, the behaviour of the driver depends on its implementation.</P
84 ><P
85 >Transactions are usually handled by a standard sequence of actions. First, the transaction is set up. Then one or more commands are executed. Based on the result of these commands, the transaction can either be aborted (rolled back) or be written to the database (committed). libdbi provides the following functions to handle these tasks:</P
86 ><P
87 ></P
88 ><DIV
89 CLASS="VARIABLELIST"
90 ><DL
91 ><DT
92 >Start a transaction</DT
93 ><DD
94 ><P
95 >Some database engines start a transaction after a connection is established, and after each transaction is finished. These database engines do not strictly need a command to start a transaction. Others work in autocommit mode, i.e. each command is automatically committed. Some of the latter can be coerced to use transactions, while others simply do not provide explicit transaction management. As a database abstraction layer, libdbi has to cover all cases by providing an explicit command to start transactions, see <A
96 HREF="reference-conn.html#DBI-CONN-TRANSACTION-BEGIN"
97 >dbi_conn_transaction_begin</A
98 >.</P
99 ></DD
100 ><DT
101 >Commit a transaction</DT
102 ><DD
103 ><P
104 >If no errors occurred during a transaction, the changes can actually be written to the database by calling <A
105 HREF="reference-conn.html#DBI-CONN-TRANSACTION-COMMIT"
106 >dbi_conn_transaction_commit</A
107 >.</P
108 ></DD
109 ><DT
110 >Rollback a transaction</DT
111 ><DD
112 ><P
113 >If an error occurred during a transaction, the database can be reverted to the state when the transaction started by calling <A
114 HREF="reference-conn.html#DBI-CONN-TRANSACTION-ROLLBACK"
115 >dbi_conn_transaction_rollback</A
116 >.</P
117 ></DD
118 ></DL
119 ></DIV
120 ></DIV
121 ><DIV
122 CLASS="NAVFOOTER"
123 ><HR
124 ALIGN="LEFT"
125 WIDTH="100%"><TABLE
126 SUMMARY="Footer navigation table"
127 WIDTH="100%"
128 BORDER="0"
129 CELLPADDING="0"
130 CELLSPACING="0"
131 ><TR
132 ><TD
133 WIDTH="33%"
134 ALIGN="left"
135 VALIGN="top"
136 ><A
137 HREF="transactions-savepoints.html"
138 ACCESSKEY="P"
139 >Prev</A
140 ></TD
141 ><TD
142 WIDTH="34%"
143 ALIGN="center"
144 VALIGN="top"
145 ><A
146 HREF="index.html"
147 ACCESSKEY="H"
148 >Home</A
149 ></TD
150 ><TD
151 WIDTH="33%"
152 ALIGN="right"
153 VALIGN="top"
154 ><A
155 HREF="savepoints.html"
156 ACCESSKEY="N"
157 >Next</A
158 ></TD
159 ></TR
160 ><TR
161 ><TD
162 WIDTH="33%"
163 ALIGN="left"
164 VALIGN="top"
165 >Transactions and Savepoints</TD
166 ><TD
167 WIDTH="34%"
168 ALIGN="center"
169 VALIGN="top"
170 ><A
171 HREF="transactions-savepoints.html"
172 ACCESSKEY="U"
173 >Up</A
174 ></TD
175 ><TD
176 WIDTH="33%"
177 ALIGN="right"
178 VALIGN="top"
179 >Savepoints</TD
180 ></TR
181 ></TABLE
182 ></DIV
183 ></BODY
184 ></HTML
185 >