DEFINE NEW SHARED PRIVATE PROTECTED STATICBUFFER buffer-nameFOR TEMP-TABLE table-namePRESELECT LABEL label-nameNAMESPACE-URI namespace NAMESPACE-PREFIX prefixXML-NODE-NAME node-nameNEW SHARED BUFFER buffer-nameSHARED BUFFER buffer-namebuffer-namePRIVATE PROTECTED STATIC BUFFER
Note: The specified options are applicable only when defining a data member for a class in a class definition (.cls) file. Note also that you cannot shadow (override) the definition of a given buffer data member in a class hierarchy.Within a class, ABL defines the default buffer for any database table as a PRIVATE instance buffer. Thus, for example, you can only access the default buffer for the Customer table of the sports2000 database wherever a PRIVATE instance buffer can be accessed. Otherwise, you must define an alternate buffer data member for the table with an appropriate access mode and scope.For more information on accessing buffers of different access modes and scopes, see the reference entry for Class-based data member access.For more information on where and how to define data members in a class, see the CLASS statement reference entry.BUFFER buffer-nameFOR TEMP-TABLE table-nameIdentifies the name of the table for which you are defining an additional buffer. This can also be the built-in buffer name, proc-text-buffer, to define a buffer that returns table rows from a stored procedure.To define a buffer for a table defined for multiple databases, you might have to qualify the table name with the database name. See the Record phrase reference entry for more information.If you define the buffer as static, and table-name is the name of a temp-table, the temp-table must also be defined as a static member of a class.LABEL label-nameNAMESPACE-URI namespaceNAMESPACE-PREFIX prefixXML-NODE-NAME node-nameThis procedure allows the user to create a new Customer record. Initially, the City, State, and Country fields are not shown. After the user enters a PostalCode value, the procedure searches for an existing Customer with the same postal code. If such a Customer is found, the City, State, and Country values from that record are displayed in the fields for the new record. The user can then update those fields.The r-defb2.p procedure gets the name of a table (such as Customer) and a condition (such as CreditLimit > 4000) and passes them as arguments to the r-defb3.p procedure:The r-defb3.p procedure:
Lets you look up a record for a Customer table. For example, the user supplies Customer as a table name; the FIND statement in the r-defb3.p procedure translates to FIND _File Customer. The FIND statement finds, in _File, the record for the Customer table.
Lets you select records. For example, the user supplies the condition CreditLimit > 4000 in the table name. The DO PRESELECT EACH rec statement translates to DO PRESELECT EACH rec WHERE MaxCredit > 4000. The AVM goes through the Customer table and selects the records that meet the criteria. It creates a temp-table containing a pointer to each of those records. This list of preselected records is associated with the rec buffer.
Runs r-defb4.p, passing the table name (Customer) and the names of all of the fields in that table.The r-defb4.p procedure has access to the rec buffer (and through it to the set of preselected records). This connection is made by using PRESELECT on the DEFINE SHARED BUFFER statement. The r-defb4.p procedure displays those records.
DEFINE SHARED BUFFER rec FOR {1} PRESELECT.
REPEAT:FIND NEXT rec.DISPLAY {2} {3} {4} {5} {6} {7} {8} {9} {10} {11} {12} {13}WITH 1 COLUMN 1 DOWN.END.Because r-defb3.p and r-defb4.p use run-time argument passing, they cannot be precompiled. Having separate versions of r-defb4.p for each table and running the appropriate one in r-defb3.p, should improve response time. This approach is worthwhile if there are many lines of code in r-defb4.p a procedure.
Missing FOR, FIND or CREATE for Customer.
/* Main procedure */DEFINE NEW SHARED BUFFER x FOR Customer.RUN proc2.p.DISPLAY x.
/* proc2.p */DEFINE SHARED BUFFER x FOR Customer.FIND FIRST x.
/* Main procedure */DEFINE NEW SHARED BUFFER x FOR Customer.
RUN proc2.p.DO FOR x:DISPLAY x.END.For examples of instance and static buffer data member definitions, see the descriptions of r-CustObj.cls, r-CustObjStatic.cls, and r-CustObjAbstract.cls in the CLASS statement reference entry.
You cannot define a SHARED or NEW SHARED buffer in a class definition (.cls) file. If you do, ABL generates a compilation error.
A buffer can be compile-time defined (often referred to as a static buffer object), where the buffer is defined and created at compile time using this statement, or it can be run-time defined (often referred to as a dynamic buffer object), where the buffer is defined and created at run time using the CREATE BUFFER statement and buffer object handle operations. A compile-time defined buffer can also be defined as a static data member of a class. In this case, it is a static buffer object that is also a class static data member.
For more information on using the built-in buffer name proc-text-buffer, see the OpenEdge DataServer Guides (OpenEdge Data Management: DataServer for Microsoft SQL Server, OpenEdge Data Management: DataServer for ODBC, and OpenEdge Data Management: DataServer for Oracle).
© 2013 Progress Software Corporation and/or its subsidiaries or affiliates. |