SQLROLLBACK()
From Recital Documentation Wiki
Revision as of 11:14, 16 December 2009 by Yvonnemilne (Talk | contribs)
Purpose
Rollback a transaction
Syntax
SQLROLLBACK(<nStatementHandle>)
See Also
CREATE CONNECTION, SQLCANCEL(), SQLCOLUMNS(), SQLCOMMIT(), SQLCONNECT(), SQLDISCONNECT(), SQLEXEC(), SQLGETPROP() SQLMORERESULTS(), SQLPREPARE(), SQLSETPROP(), SQLSTRINGCONNECT(), SQLTABLES()
Description
The SQLROLLBACK() function is used to roll back a transaction. The SQLROLLBACK() function is only required when Manual Transactions are in effect. The Transactions setting, set using SQLSETPROP(), can be either Automatic (1) or Manual (2). Manual Transactions can be can be committed using the SQLCOMMIT() function.
The SQLROLLBACK() function operates on the data source specified by <nStatementHandle>.
Keywords | Description |
---|---|
nStatementHandle | The workarea in which the gateway data source is open |
Return values:
Return Value | Description |
---|---|
1 | SQL statement was rolled back successfully |
–1 | Error occurred |
Example
nStatHand=SQLSTRINGCONNECT("rec@rec1:user1/pass1/usr/recital/uas/data/southwind.tcpip",.T.) if nStatHand < 1 messagebox("Cannot make connection", 16, "SQL Connect Error") else messagebox("Connection made", 48, "SQL Connect Message") nSetEnd = SQLSETPROP(nStatHand,"Transactions",2) if nSetEnd = 1 dialog box [Manual Transactions enabled] else dialog message [Unable to enable Manual Transactions. Continue?] if lastkey() <> 89 SQLDISCONNECT(nStatHand) return endif endif nRET=SQLEXEC(nStatHand,"INSERT INTO example (ACCOUNT_NO, TITLE, LAST_NAME, FIRST_NAME, INITIAL, STREET, CITY, STATE, ZIP, LIMIT, START_DATE) VALUES ('00200','Mr','Doe','John','L','1 High Street','Beverly','MA','01916', 12000, {05/12/2003})") if SQLGETPROP(nStatHand, "Transactions") = 2 dialog message [Commit Insert?] if lastkey() = 89 dialog box "SQLCOMMIT() returned " + etos(SQLCOMMIT(nStatHand)) else dialog box "SQLROLLBACK() returned " + etos(SQLROLLBACK(nStatHand)) endif endif nSetEnd = SQLSETPROP(nStatHand, "Transactions",1) if nSetEnd = 1 dialog box [Automatic Transactions enabled] else dialog message [Unable to enable Automatic Transactions.] endif endif SQLDISCONNECT(nStatHand)
Products
Recital, Recital Server