Using the macros sc_begin_trans, sc_commit_trans and sc_rollback_trans

Using the macros sc_begin_trans, sc_commit_trans and sc_rollback_trans

When we need to maintain a control or follow-up to a specific procedure at the time of entering, modify some procedure within the database within a form we have the macro sc_begin_trans.


The macro sc_begin_trans is responsible for carrying out a transaction control procedure within theScriptCase, but it can also be complemented with the macrossc_commit_trans and sc_rollback.


Now, the macro sc_commit_trans is loaded that once the control process has been carried out, it can be by means of a condition, it confirms the transaction, that is, if all the proposed conditions are fulfilled, it confirms the transaction, it can be that of inserting, modify or delete a record.


Otherwise it is the macro sc_rollback_trans that is responsible for canceling the transactions given by the user, for example, when wanting to enter, modify or delete a record, this is responsible for canceling or omitting the procedure.


Then, in the following example, it is responsible for making a control when registering:


1. Within the AfterInsert event a control is made after entering:

2. When executing, we enter a code other than 85:


Depending on the condition, if the entered code is not 85, then confirm the transaction with the macro sc_commit_trans.


3. Otherwise, we enter a record with code 85:


4. Then within our database administrator you can see that the record was not loaded with code 85, that's thanks to the macro sc_rollback_trans:


      

    • Related Articles

    • Using macros sc_begin_trans, sc_commit_trans and sc_rollback_trans with Alert Message

      When we need to maintain a control or follow-up to a specific procedure at the time of entering, modify some procedure within the database within a form we have the macro sc_begin_trans. The macro sc_begin_trans is responsible for carrying out a ...
    • Using sc_ajax_refresh()

      -Create a grid -At the Ajax Event -New Ajax Event: -Select the Event onClick and the desired field, and create: -Add the following macro: sc_ajax_refresh (); -When clicking on the record in that field, the page would be reloading Corresponding ...
    • Using the sc_confirm macro

      In this article, see a practical example of using the sc_confirm macro. This macro can only be used on PHP buttons created in the toolbar of form and control applications, with the aim of confirming the action's excursion. See how to create a PHP ...
    • Using the macro sc_date_dif_2

      To calculate the difference between two dates we have the macro sc_date_dif_2, in this example we will see how it works and how to use it. 1. The format with which you are keeping within the database must be taken into account: Database Format Macro ...
    • Using ajax: onChange events

      In this article we will see how the onChange event works, available in Scriptcase. It is triggered when the object, which makes use of it, has its value changed. Down below is an example of using this event. We will use an order items form, we will ...