📄 transactions.html
字号:
<html>
<head>
<meta name="KEYWORDS" content="
library, C++,
Oracle, SQLServer, DB2, Sybase, Informix, InterBase, SQLBase, ODBC,
SQL, server, client, database, programming, development, software,
Win32, Windows, Linux, Unix, Solaris,
Microsoft, Borland, Centura, Gupta, IBM">
<meta name="DESCRIPTION" content="SQLAPI++ is C++ library for accessing SQL databases (Oracle, SQLServer, Sybase, DB2, InterBase, SQLBase, Informix, ODBC).
It uses native APIs, provides low-level access to database-specific features.">
<title>SQLAPI++ Library - How To - Transactions</title>
</head>
<body bgcolor="#ffffff" BACKGROUND="../images/bg.gif" text="#000000"><!--class="GlbHdr"-->
<table WIDTH="600" height="40" frame="hsides" BORDER="2" BORDERCOLOR="#004fcd" align="right" cellpadding="0" cellspacing="2" id="TABLE1">
<tr><!--class="GlbDefault"-->
<td width="70" bgcolor="#000094" bordercolor="black" align="middle"><A href="../index.html" style="TEXT-DECORATION: none">
<font color="white" size="3" face="sans-serif">
<b>Home</b></font></A></td></TD>
<!--class="GlbActive"-->
<td width="70" bgcolor="#00bb00" bordercolor="black" align="middle"><A href="index.html" style="TEXT-DECORATION: none">
<font color="white" size="3" face="sans-serif">
<b>How To</b></font></A></td>
<!--class="GlbDefault"-->
<td width="70" bgcolor="#000094" bordercolor="black" align="middle"><A href="../OnLineDoc/index.html" style="TEXT-DECORATION: none">
<font color="white" size="3" face="sans-serif">
<b>Online Documentation</b></font></A></td><!--class="GlbDefault"-->
<td width="70" bgcolor="#000094" bordercolor="black" align="middle"><A href="../Support/index.html" style="TEXT-DECORATION: none">
<font color="white" size="3" face="sans-serif">
<b>Support</b></font></A></td>
<td width="70" bgcolor="#000094" bordercolor="black" align="middle"><A href="../Download/index.html" style="TEXT-DECORATION: none">
<font color="white" size="3" face="sans-serif">
<b>Download</b></font></A></td>
<td width="70" bgcolor="#000094" bordercolor="black" align="middle"><A href="../Order/index.html" style="TEXT-DECORATION: none">
<font color="white" size="3" face="sans-serif">
<b>Order</b></font></A></td>
</tr>
</table>
<p> </p>
<p> </p>
<table width="100%" cellpadding="1" cellspacing="1">
<tr>
<td valign="top" align="left"><!--class="LeftMenu"-->
<table frame="void" CELLSPACING="2" cellpadding="2" width="165">
<tr>
<td><img align="middle" src="../images/green.gif" WIDTH="12" HEIGHT="12">
<A href="connect.html" style="TEXT-DECORATION: none">
<font color="white" size="2" face="sans-serif">
Connecting to databases</font></A> </td>
</tr>
<tr>
<td><img align="middle" src="../images/red.gif" WIDTH="12" HEIGHT="12">
<A href="transactions.html" style ="TEXT-DECORATION: none" >
<font color="white" face="sans-serif" size=2>
Transactions</font></A> </td>
</tr>
<tr>
<td><img align="middle" src="../images/green.gif" WIDTH="12" HEIGHT="12">
<A href="commands.html" style="TEXT-DECORATION: none">
<font color="white" size="2" face="sans-serif">
Executing an SQL command</A> </FONT> </td>
</tr>
<tr>
<td><img align="middle" src="../images/green.gif" WIDTH="12" HEIGHT="12">
<A href="procedures.html" style="TEXT-DECORATION: none">
<font color="white" size="2" face="sans-serif">
Executing stored procedures</A>
</FONT> </td>
</tr>
<tr>
<td><img align="middle" src="../images/green.gif" WIDTH="12" HEIGHT="12">
<A href="bind.html" style="TEXT-DECORATION: none">
<font color="white" size="2" face="sans-serif">
Binding input parameters</A> </FONT> </td>
</tr>
<tr>
<td><img align="middle" src="../images/green.gif" WIDTH="12" HEIGHT="12">
<A href="fetch.html" style="TEXT-DECORATION: none">
<font color="white" size="2" face="sans-serif">
Fetching result set</A> </FONT> </td>
</tr>
<tr>
<td><img align="middle" src="../images/green.gif" WIDTH="12" HEIGHT="12">
<A href="fetch_multiple.html" style="TEXT-DECORATION: none">
<font color="white" size="2" face="sans-serif">
Fetching multiple result sets</A> </FONT> </td>
</tr>
<tr>
<td><img align="middle" src="../images/green.gif" WIDTH="12" HEIGHT="12"
>
<A href="performance.html" style ="TEXT-DECORATION: none" >
<font color="white" size="2" face="sans-serif">
Optimizing Database Performance</A> </FONT> </td>
</tr>
<tr>
<td><img align="middle" src="../images/green.gif" WIDTH="12" HEIGHT="12">
<A href="return_param.html" style="TEXT-DECORATION: none">
<font color="white" size="2" face="sans-serif">
Returning output parameters</A> </FONT> </td>
</tr>
<tr>
<td><img align="middle" src="../images/green.gif" WIDTH="12" HEIGHT="12" alt ="" border="0" hspace="0" style ="HEIGHT: 12px; WIDTH: 12px" useMap="">
<A href="blobs.html" style="TEXT-DECORATION: none">
<font color="white" size="2" face="sans-serif">
Working with
Long or Lob(CLob, BLob) Data</A> </FONT> </td>
</tr>
<tr>
<td><img align="middle" src="../images/green.gif" WIDTH="12" HEIGHT="12"><A href="datetime.html" style="TEXT-DECORATION: none">
<font color="white" size="2" face="sans-serif">
Working with date/time values</A> </FONT> </td>
</tr>
<tr>
<td><img align="middle" src="../images/green.gif" WIDTH="12" HEIGHT="12">
<A href="errors.html" style="TEXT-DECORATION: none">
<font color="white" size="2" face="sans-serif">
Error handling</A> </FONT> </td>
</tr>
<tr>
<td><img align="middle" src="../images/green.gif" WIDTH="12" HEIGHT="12">
<A href="query_exampl.html" style="TEXT-DECORATION: none">
<font color="white" size="2" face="sans-serif">
Query examples</A> </FONT> </td>
</tr>
</table>
</td>
<td width="30">
<p> </p>
</td>
<td valign="top">
<center>
<h1> Transactions</h1>
</center>
<p>A <I>transaction</I>
is a unit of work that
is done as a single operation. There are two base characteristics of
transaction:</p>
<UL>
<LI><A href="#Transaction mode">Transaction mode</A>
<LI><A href="#Transaction Isolation Level">Transaction Isolation
Level</A></LI></UL>
<H3><A name="Transaction mode">Transaction mode</A></H3>
<p>
Transactions can be completed by
either being <I>committed</I>
or being <I>rolled back</I>. When a
transaction is committed, the changes made in that transaction are
made permanent. When a transaction is rolled back, the affected rows
are returned to the state they were in before the transaction was
started.</p>
<p>Transactions can be in one of two modes:
<STRONG>auto-commit</STRONG>
mode or <STRONG>manual-commit</STRONG>
mode.</p>
<p><I>In auto-commit mode,</I> every database
operation is a transaction that is committed when performed. In
databases without transaction support, auto-commit mode is the only
supported mode. In such databases, statements are committed when
they are executed and there is no way to roll them back; they are
therefore always in auto-commit mode.</p>
<p><I>In manual-commit mode,</I>
applications must explicitly complete transactions by
calling <A
href="../OnLineDoc/Connection_Commit.html">SAConnection::Commit</A>
to commit them or <A
href="../OnLineDoc/Connection_Rollback.html">SAConnection::Rollback</A>
to roll them back. This is
the normal transaction mode for most relational databases.</p>
<p><STRONG>Note: The default transaction settings
are DBMS-defined. </STRONG></p>
<p>Using SQLAPI++ to set
auto-commit mode compulsory you should call <A
href="../OnLineDoc/Connection_setAutoCommit.html">SAConnection::setAutoCommit</A>
method with parameter value <STRONG>SA_AutoCommitOn</STRONG>. To set
manual-commit mode you should call <A
href="../OnLineDoc/Connection_setAutoCommit.html">SAConnection::setAutoCommit</A>
method with parameter value <STRONG>SA_AutoCommitOff</STRONG>. If you didn't set transaction mode
explicitly then the Library
uses the default DBMS transaction settings. See DBMS documentation to get information
concerning the default transaction mode.</p>
<p>If you disconnected from server without
commit, then the result of
transaction depends on underlying DBMS. It can either being committed or being
rolled back. See DBMS documentation.</p>
<p>
Calling <A
href="..\OnLineDoc\Connection_Commit.html" >SAConnection::Commit</A>
or <A
href="..\OnLineDoc\Connection_Rollback.html" >SAConnection::Rollback</A>
in
auto-commit is safe (it has no effect). If you
are working in manual-commit mode and
call <A
href="..\OnLineDoc\Connection_Commit.html" >SAConnection::Commit</A> method
then current transaction is committed and new one is started. If you
are working in
manual-commit mode and call <A
href="..\OnLineDoc\Connection_Rollback.html" >SAConnection::Rollback</A>
method then current transaction is rolled back
and new one is started.</p>
<H3><A name="Transaction Isolation Level">Transaction Isolation
Level</A></H3>
<p><I>Transaction isolation</I> refers to the
degree of interaction between multiple concurrent transactions.
SQL-92 defines four isolation levels, all of which are supported by
SQLAPI++:</p>
<UL>
<LI>Read uncommitted (the lowest level
where transactions are isolated just enough to ensure that
physically corrupt data is not read)
<LI>Read committed
<LI>Repeatable read
<LI>Serializable (the highest level, where
transactions are completely isolated from one another)</LI></UL>
<P> SQLAPI++ maps different isolation levels on
underlying DBMS. You can set transaction isolation level explicitly
by calling <A
href="../OnLineDoc/Connection_setIsolationLevel.html">SAConnection::setIsolationLevel</A>
.</P>
<P> If you didn't set transaction isolation
level explicitly then the Library uses the default DBMS transaction
settings. See DBMS documentation to get
information concerning the default transaction isolation level.</P>
<P> Note that if you change isolation level it
causes implicit commit for this connection. </P>
<h3>Problems and Questions</h3>
<p>If you don't find the answer to you questions or have some problems on
using the Library, please, send e-mail to <A href="mailto:howto@sqlapi.com">howto@sqlapi.com</A>. </p>
<p> </p>
</td>
<tr></tr>
</table></FONT>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -