Difference between revisions of "SQLROLLBACK()"
From Lianjapedia
Yvonne.milne (Talk | contribs) m (1 revision: SQL) |
Helen.george (Talk | contribs) |
||
(7 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
==Purpose== | ==Purpose== | ||
Rollback a transaction | Rollback a transaction | ||
− | |||
==Syntax== | ==Syntax== | ||
SQLROLLBACK(<nStatementHandle>) | SQLROLLBACK(<nStatementHandle>) | ||
− | |||
==See Also== | ==See Also== | ||
− | + | [[SQLCANCEL()]], [[SQLCOLUMNS()]], [[SQLCOMMIT()]], [[SQLCONNECT()]], [[SQLDISCONNECT()]], [[SQLERROR()]], [[SQLEXEC()]], [[SQLGETPROP()]] [[SQLMORERESULTS()]], [[SQLPREPARE()]], [[SQLSETPROP()]], [[SQLSTRINGCONNECT()]], [[SQLTABLES()]], [[SQLTRANSACTION()]] | |
− | + | ||
==Description== | ==Description== | ||
− | The SQLROLLBACK() function is used to | + | The SQLROLLBACK() function is used to commit a transaction. The SQLROLLBACK() function is only required when SQLTRANSACTION() is in effect on the connection. |
+ | The SQLROLLBACK() function operates on the ODBC connection specified by <nStatementHandle>. | ||
The SQLROLLBACK() function operates on the data source specified by <nStatementHandle>. | The SQLROLLBACK() function operates on the data source specified by <nStatementHandle>. | ||
− | + | {| class="wikitable" width="100%" | |
− | {| class="wikitable" | + | !width="30%"|Keywords||width="70%"|Description |
− | !Keywords||Description | + | |
|- | |- | ||
− | |nStatementHandle|| | + | |nStatementHandle||Statement handle to the connection |
|- | |- | ||
|} | |} | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
==Example== | ==Example== | ||
<code lang="recital"> | <code lang="recital"> | ||
− | nStatHand= | + | nStatHand=sqlconnect("awhr") |
if nStatHand < 1 | if nStatHand < 1 | ||
− | + | messagebox("Cannot make connection", 16, "SQL Connect Error") | |
else | else | ||
− | + | messagebox("Connection made", 48, "SQL Connect Message") | |
− | + | sqltransaction(nStatHand) | |
− | + | sqlexec(nStatHand,"insert into dbo.doc1 (account_no, lastname, balance) values ('00889','Brown', 12000)") | |
− | + | if messagebox("Commit Insert?",36,"Transaction") = 6 | |
− | + | sqlcommit(nStatHand) | |
− | + | else | |
− | + | sqlrollback(nStatHand) | |
− | + | endif | |
− | + | sqlexec(nStatHand,"select * from dbo.doc1") | |
− | + | list | |
− | + | sqldisconnect(nStatHand) | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
endif | endif | ||
− | |||
</code> | </code> | ||
− | |||
− | |||
− | |||
− | |||
[[Category:Documentation]] | [[Category:Documentation]] | ||
[[Category:Functions]] | [[Category:Functions]] | ||
[[Category:SQL]] | [[Category:SQL]] | ||
− | [[Category: | + | [[Category:ODBC Functions]] |
+ | [[Category:SQL Functions]] |
Latest revision as of 10:01, 4 February 2013
Contents
Purpose
Rollback a transaction
Syntax
SQLROLLBACK(<nStatementHandle>)
See Also
SQLCANCEL(), SQLCOLUMNS(), SQLCOMMIT(), SQLCONNECT(), SQLDISCONNECT(), SQLERROR(), SQLEXEC(), SQLGETPROP() SQLMORERESULTS(), SQLPREPARE(), SQLSETPROP(), SQLSTRINGCONNECT(), SQLTABLES(), SQLTRANSACTION()
Description
The SQLROLLBACK() function is used to commit a transaction. The SQLROLLBACK() function is only required when SQLTRANSACTION() is in effect on the connection. The SQLROLLBACK() function operates on the ODBC connection specified by <nStatementHandle>.
The SQLROLLBACK() function operates on the data source specified by <nStatementHandle>.
Keywords | Description |
---|---|
nStatementHandle | Statement handle to the connection |
Example
nStatHand=sqlconnect("awhr") if nStatHand < 1 messagebox("Cannot make connection", 16, "SQL Connect Error") else messagebox("Connection made", 48, "SQL Connect Message") sqltransaction(nStatHand) sqlexec(nStatHand,"insert into dbo.doc1 (account_no, lastname, balance) values ('00889','Brown', 12000)") if messagebox("Commit Insert?",36,"Transaction") = 6 sqlcommit(nStatHand) else sqlrollback(nStatHand) endif sqlexec(nStatHand,"select * from dbo.doc1") list sqldisconnect(nStatHand) endif