f2s_esql_rollback_transaction

Applies to: Oracle, MS SQL, MySql/MariaDB, PostgreSQL Drivers

Syntax

f2s_esql_rollback_transaction

Description

This command is used to rollback a SQL transaction. Any SQL changes inside the transaction will not be committed by the server. This rolls back a transaction to it’s original state and any modifications are erased.

Example

f2s_esql_rollback_transaction Command using SQL Server
     String sSQL
     String sCustName
     String sCustAddress
     String sCustCity
     String sCustState
     String sCustZip
     String sCustPhone_Number
     Number nCreditLimit nMaximumAllowedCreditLimit
     Move 250.00 to nMaximumAllowedCreditLimit
     Move "Test Name" to sCustName
     Move "123 Test Address" to sCustAddress
     Move "Miami" to sCustCity
     Move "FL" to sCustState
     Move "33308" to sCustZip
     Move "305 555-5555" to sCustPhone_Number
     Move 1000.00 to nCreditLimit
     Move "Insert into CUSTOMER ([Name], [Address], [City], [State], [Zip], [Phone_Number],[Credit_Limit]) Values(?,?,?,?,?,?,?)" to sSQL

     //Start a Transaction
     f2s_esql_start_transaction

     //Create the SQL Statement
     f2s_esql_create_stmt sSQL

     // Prepare the SQL Statement
     f2s_esql_prepare_stmt

     // Set the parameter values for the SQL Statement
     f2s_esql_set_param 1 to sCustName
     f2s_esql_set_param 2 to sCustAddress
     f2s_esql_set_param 3 to sCustCity
     f2s_esql_set_param 4 to sCustState
     f2s_esql_set_param 5 to sCustZip
     f2s_esql_set_param 6 to sCustPhone_Number
     f2s_esql_set_param 7 to nCreditLimit

     //Execute the SQL Statement
     f2s_esql_execute_stmt

     //Check  Business rule for new customers with a high Credit Limit
     If (nCreditLimit > nMaximumAllowedCreditLimit) Begin
         Showln "Credit Limit is too high!  Rolling back the transaction."
         f2s_esql_rollback_transaction
     End
     Else Begin
         Showln "Successful - Committing the Transaction"
         f2s_esql_commit_transaction
     End
     f2s_esql_close_stmt
     inkey WindowIndex

Related Commands

  • f2s_esql_start_transaction

  • f2s_esql_commit_transaction

Replaces: Command SQL_ROLLBACK_STMT