Update the database directly with commands VERSUS using Business Components

Official Content
This documentation is valid for:

There are two available ways for updating a database in a procedure:

  • Direct insertion with New command (this code can only be included in a procedure source):
          CustomerId = &CustomeriId
          CustomerName = &CustomerName
  • Insertion using the business components concept (this code can be included in a procedure source and in other GeneXus objects in it's events section):
       &Customer.CustomerId = &CustomerId
       &Customer.CustomerName = &CustomerName

The question is, which of these two methods is better?

The answer, as often happens, is: it depends! From the point of view of performance, the first method is preferred, since there are no controls involved and the generated SQL sentence will be optimized for bulk updates. On the other hand, from the point of view of consistency, the second method is best, since all the controls will be enforced independently if data comes from a Form or from a procedure.

So a good rule of thumb would be to always use Business Components unless performance is critical.