Compartir a través de


SQLROLLBACK( ) Function

Cancels any changes made during the current transaction.

SQLROLLBACK(nStatementHandle)

Parameters

  • nStatementHandle
    Specifies the statement handle to the data source returned by SQLCONNECT( ).

Return Value

Numeric. SQLROLLBACK( ) returns 1 if the transaction is successfully rolled back; otherwise, it returns -1. If SQLROLLBACK( ) returns -1, you can use AERROR( ) to determine why the transaction could not be rolled back.

Remarks

If manual transactions are in effect (the SQLSETPROP( ) transaction property is set to manual), you can send multiple updates to remote tables. The updates can all be rolled back with SQLROLLBACK( ).

Updates can be committed with SQLCOMMIT( ).

Example

The following example assumes SQLCONNECT( ) is successfully issued, and its return value is stored to a memory variable named gnHandle. SQLSETPROP( ) is used to set the Transactions property to 2 (manual), making it possible for you to use SQLCOMMIT( ) and SQLROLLBACK( ).

The authors table is modified with SQLEXEC( ), and the changes to the table are cancelled with SQLROLLBACK( ).

= SQLSETPROP(gnHandle, 'Transactions', 2)  && manual
= SQLEXEC(gnHandle, "INSERT INTO authors (au_id, au_lname);
   VALUES ('aupoe', 'Poe')")
= SQLROLLBACK(gnHandle)

See Also

Reference

AERROR( ) Function

SQLCOMMIT( ) Function

SQLCONNECT( ) Function

SQLSETPROP( ) Function

SQL Commands and Functions

Other Resources

Language Reference (Visual FoxPro)