Buffers

KleineCuypie

New Member
Buffers can be used in different ways. For example when u have to get a value from a tablerecord and use it in a new record you'll need a buffer.

Code:
DEFINE BUFFER b_customer FOR customer.
FIND FIRST customer WHERE id = 1.
IF AVAIL customer THEN DO:
  CREATE b_customer.
  b_customer.id = 2.
  b_customer.sameValueField = customer.sameValueField.
END.
 

RealHeavyDude

Well-Known Member
Basically you need to understand what buffer scope is in order to understand why it is a good idea to use named buffers instead of the default buffer (which equals the database table name) in the first place. I'll suggest you to read the corresponding section in the programming handbook (which is part of the documentation that comes with the product).

Bottom line: A key factor in writing good ABL programs is to understand how buffer and transaction scope work. Using named buffers and strong buffer and transaction scopes makes it easy to prevent all sorts of unwanted application behavior like (to name just a few important ones):
  • Unnecessary big transaction make the before image grow larger than it needs to be and possibly blowing the lock table.
  • Avoiding SHARE-LOCKS (talking about these in detail would be a separate discussion)
  • Controlling when database triggers fire (if they are used)
My recommendation: All code that updates the database should do so only using named buffers and strong buffer scope.

Heavy Regards, RealHeavyDude.
 

tamhas

ProgressTalk.com Sponsor
Actually, you are always using a buffer when you access a database table or temp-table, it is just the default buffer with the same name as the table. Using named buffers allows you to control scope. I am with RHD in recommending that you strongly scope all interaction with the database by using named buffers.
 
Top