ibm-information-center/dist/eclipse/plugins/i5OS.ic.cli_5.4.0.1/rzadpfntrans.htm

161 lines
9.1 KiB
HTML
Raw Permalink Normal View History

2024-04-02 14:02:31 +00:00
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="security" content="public" />
<meta name="Robots" content="index,follow" />
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta name="DC.Type" content="reference" />
<meta name="DC.Title" content="SQLTransact - Commit or roll back transaction" />
<meta name="DC.Relation" scheme="URI" content="rzadphdapi.htm" />
<meta name="DC.Relation" scheme="URI" content="rzadpefftrans.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 1999, 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 1999, 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="rzadpfntrans" />
<meta name="DC.Language" content="en-us" />
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
<link rel="stylesheet" type="text/css" href="./ic.css" />
<title>SQLTransact</title>
</head>
<body id="rzadpfntrans"><a name="rzadpfntrans"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">SQLTransact - Commit or roll back transaction</h1>
<div><div class="section"></div>
<div class="section"><h4 class="sectiontitle">Purpose</h4> <p><samp class="codeph">SQLTransact()</samp> commits
or rolls back the current transaction in the connection.</p>
<p>All changes
to the database performed on the connection since connect time or the previous
call to <samp class="codeph">SQLTransact()</samp> (whichever is the most recent) are
committed or rolled back.</p>
<p>If a transaction is active on a connection,
the application must call <samp class="codeph">SQLTransact()</samp> before it can disconnect
from the database.</p>
</div>
<div class="section"><h4 class="sectiontitle">Syntax</h4><pre>SQLRETURN SQLTransact (SQLHENV henv,
SQLHDBC hdbc,
SQLSMALLINT fType);</pre>
</div>
<div class="section"><h4 class="sectiontitle">Function arguments</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" width="100%" frame="hsides" border="1" rules="all"><caption>Table 1. SQLTransact arguments</caption><thead align="left"><tr><th align="left" valign="top" width="20%" id="d0e61">Data type</th>
<th align="left" valign="top" width="20%" id="d0e63">Argument</th>
<th align="left" valign="top" width="20%" id="d0e65">Use</th>
<th align="left" valign="top" width="40%" id="d0e67">Description</th>
</tr>
</thead>
<tbody><tr><td align="left" valign="top" width="20%" headers="d0e61 ">SQLHDBC</td>
<td align="left" valign="top" width="20%" headers="d0e63 "><em>hdbc</em></td>
<td align="left" valign="top" width="20%" headers="d0e65 ">Input</td>
<td align="left" valign="top" width="40%" headers="d0e67 ">Database connection handle. <p>If <em>hdbc</em> is
set to SQL_NULL_HDBC, then <em>henv</em> must contain the environment handle
that the connection is associated with.</p>
</td>
</tr>
<tr><td align="left" valign="top" width="20%" headers="d0e61 ">SQLHENV</td>
<td align="left" valign="top" width="20%" headers="d0e63 "><em>henv</em></td>
<td align="left" valign="top" width="20%" headers="d0e65 ">Input</td>
<td align="left" valign="top" width="40%" headers="d0e67 ">Environment handle. <p>If <em>hdbc</em> is
a valid connection handle, <em>henv</em> is ignored.</p>
</td>
</tr>
<tr><td align="left" valign="top" width="20%" headers="d0e61 ">SQLSMALLINT</td>
<td align="left" valign="top" width="20%" headers="d0e63 "><em>fType</em></td>
<td align="left" valign="top" width="20%" headers="d0e65 ">Input</td>
<td align="left" valign="top" width="40%" headers="d0e67 ">The wanted action for the transaction. The
value for this argument must be one of: <ul><li>SQL_COMMIT</li>
<li>SQL_ROLLBACK</li>
<li>SQL_COMMIT_HOLD</li>
<li>SQL_ROLLBACK_HOLD</li>
</ul>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section"><h4 class="sectiontitle">Usage</h4><div class="p">Completing a transaction with SQL_COMMIT or
SQL_ROLLBACK has the following effects: <ul><li>Statement handles are still valid after a call to <samp class="codeph">SQLTransact()</samp>.</li>
<li>Cursor names, bound parameters, and column bindings survive transactions.</li>
<li>Open cursors are closed, and any result sets that are pending retrieval
are discarded.</li>
</ul>
</div>
<p>Completing the transaction with SQL_COMMIT_HOLD or SQL_ROLLBACK_HOLD
still commits or rolls back the database changes, but does not cause cursors
to be closed.</p>
<p>If no transaction is currently active on the connection,
calling <samp class="codeph">SQLTransact()</samp> has no effect on the database server
and returns SQL_SUCCESS.</p>
<p><samp class="codeph">SQLTransact()</samp> might fail while
executing the COMMIT or ROLLBACK due to a loss of connection. In this case
the application might be unable to determine whether the COMMIT or ROLLBACK
has been processed, and a database administrator's help might be required.
Refer to the DBMS product information for more information about transaction
logs and other transaction management tasks.</p>
</div>
<div class="section"><h4 class="sectiontitle">Return codes</h4><ul><li>SQL_SUCCESS</li>
<li>SQL_ERROR</li>
<li>SQL_INVALID_HANDLE</li>
</ul>
</div>
<div class="section"><h4 class="sectiontitle">Diagnostics</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" width="100%" frame="hsides" border="1" rules="rows"><caption>Table 2. SQLTransact SQLSTATEs</caption><thead align="left"><tr><th align="left" valign="top" width="25%" id="d0e176">SQLSTATE</th>
<th align="left" valign="top" width="25%" id="d0e178">Description</th>
<th align="left" valign="top" width="50%" id="d0e180">Explanation</th>
</tr>
</thead>
<tbody><tr><td align="left" valign="top" width="25%" headers="d0e176 "><strong>08</strong>003</td>
<td align="left" valign="top" width="25%" headers="d0e178 ">Connection not open</td>
<td align="left" valign="top" width="50%" headers="d0e180 ">The <em>hdbc</em> is not in a connected state.</td>
</tr>
<tr><td align="left" valign="top" width="25%" headers="d0e176 "><strong>08</strong>007</td>
<td align="left" valign="top" width="25%" headers="d0e178 ">Connection failure during transaction</td>
<td align="left" valign="top" width="50%" headers="d0e180 ">The connection associated with the <em>hdbc</em> fails
during the processing of the function during the processing of the function
and it cannot be determined whether the requested COMMIT or ROLLBACK occurs
before the failure.</td>
</tr>
<tr><td align="left" valign="top" width="25%" headers="d0e176 "><strong>58</strong>004</td>
<td align="left" valign="top" width="25%" headers="d0e178 ">System error</td>
<td align="left" valign="top" width="50%" headers="d0e180 ">Unrecoverable system error.</td>
</tr>
<tr><td align="left" valign="top" width="25%" headers="d0e176 "><strong>HY</strong>001</td>
<td align="left" valign="top" width="25%" headers="d0e178 ">Memory allocation failure</td>
<td align="left" valign="top" width="50%" headers="d0e180 ">The driver is unable to allocate memory required
to support the processing or completion of the function.</td>
</tr>
<tr><td align="left" valign="top" width="25%" headers="d0e176 "><strong>HY</strong>012</td>
<td align="left" valign="top" width="25%" headers="d0e178 ">Transaction operation state that is not valid</td>
<td align="left" valign="top" width="50%" headers="d0e180 ">The value specified for the argument <em>fType</em> is
neither SQL_COMMIT nor SQL_ROLLBACK.</td>
</tr>
<tr><td align="left" valign="top" width="25%" headers="d0e176 "><strong>HY</strong>013 <strong>*</strong></td>
<td align="left" valign="top" width="25%" headers="d0e178 ">Memory management problem</td>
<td align="left" valign="top" width="50%" headers="d0e180 ">The driver is unable to access memory required
to support the processing or completion of the function.</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section"><h4 class="sectiontitle">Example</h4></div>
<div class="example" id="rzadpfntrans__xmtrans"><a name="rzadpfntrans__xmtrans"><!-- --></a><p>Refer to the example
in <a href="rzadpfnfetch.htm">SQLFetch - Fetch next row</a></p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzadphdapi.htm" title="This topic provides a description of each CLI function.">DB2 UDB CLI functions</a></div>
</div>
<div class="relconcepts"><strong>Related concepts</strong><br />
<div><a href="rzadpefftrans.htm">Effects of calling SQLTransact() in a DB2 UDB CLI application</a></div>
</div>
</div>
</body>
</html>