Commit command

Official Content
This documentation is valid for:

The Commit command sets the succesfull end of a set of database changes. The set of database changes between Commit (or Rollback commands is treated as a single unit (called Logical Unit of Work (LUW)). A Commit command assures that the set of changes are all (or none, if any error arises) applied to the Database.

If a Knowledge Base has multiple Data Stores, a Commit command executes a Commit on every one of them that is active (i.e. where database changes have been performed) at the time the command is executed.

Issuing a Commit command also releases any database locks that have been acquired.

Unless the Commitment property has been disabled, GeneXus activates Commitment Control for all Procedures and Transactions. If the Commit on Exit property is set to Yes, it also generates a Commit at the end of each object that updates the database.

The Commit command can be specified anywhere in the program source of procedures.

This will force GeneXus to generate a Commit command. When a Commit command is included within a For Each sentence, the Commit is executed just before the EndFor always (regardless of where it was included within the For Each sentence).

Syntax

Commit

Notes

  • Many DBMSs impose a limit in the number of database changes in a LUW.

Take this into account when designing batch processes that work with a large number of rows. You may need to "break" a big LUW into smaller ones by issuing Commit commands as appropriate.

  • Many DBMSs close all open cursors when a Commit is executed.

This is a very important portability issue. You may face this problem in a For Each group that has (or calls an object that has) a Commit command.

  • A Commit command in a For Each is always executed just before the EndFor.

No matter where you wrote the Commit command inside a For Each group, if it is executed, an internal flag is set so as to actually perform a Commit to the database just before the EndFor and after performing any Database changes that the For Each may have had.

Example

Given the table Invoice:

InvoiceNumber*
InvoiceDate
ClientNumber
InvoiceAmount

Let us assume that a Commit will be performed, each time 10 invoices are deleted. This could be done as follows:

&i = 0
For each InvoiceNumber // Invoice
    where InvoiceDate >= &FirstDate
    where InvoiceDate <= &LastDate
          &i = &i + 1
          delete
          If &i = 10
             commit
             &i = 0
          EndIf
EndFor

Scope

Objects Procedure object, Web Panel object
Languages .NET, Ruby, Java, RPG, Visual Fox Pro, Cobol

 

See Also

Rollback command
Commitment property
Commit on Exit property
Confirm Transactions property

 





Was this page helpful?
What Is This?
Your feedback about this content is important. Let us know what you think.