DEF VAR lhQuery AS HANDLE NO-UNDO.
DEF VAR lhBuffer AS HANDLE NO-UNDO.
DEF VAR lhTempTable AS HANDLE NO-UNDO.
DEF VAR lhTempBuffer AS HANDLE NO-UNDO.
lhBuffer = BUFFER Customer:HANDLE.
CREATE TEMP-TABLE lhTempTable.
lhTempTable:CREATE-LIKE(lhBuffer).
lhTempTable:TEMP-TABLE-PREPARE(lhBuffer:TABLE).
lhTempBuffer = lhTempTable :DEFAULT-BUFFER-HANDLE.
CREATE QUERY lhQuery.
lhQuery:ADD-BUFFER(lhBuffer).
lhQuery:QUERY-PREPARE("FOR EACH Customer NO-LOCK":U).
lhQuery:QUERY-OPEN.
lhQuery:GET-FIRST(NO-LOCK).
DO WHILE NOT lhQuery:QUERY-OFF-END:
lhTempBuffer:BUFFER-CREATE.
lhTempBuffer:BUFFER-COPY(lhBuffer).
lhQuery:GET-NEXT(NO-LOCK).
END.
DEF VAR lhTarget AS HANDLE NO-UNDO.
DEF VAR lhSource AS HANDLE NO-UNDO.
.. (define and open the query etc)
DO WHILE NOT lhQuery:QUERY-OFF-END:
lhTempBuffer:BUFFER-CREATE.
ASSIGN lhTarget = lhTempBuffer:BUFFER-FIELD("CustomerNo")
lhSource = lhBuffer:BUFFER-FIELD("CustomerID")
lhTarget:BUFFER-VALUE = lhSource:BUFFER-VALUE
lhSource = lhBuffer:BUFFER-FIELD(...)
lhTerget = lhTempBuffer:BUFFER-FIELD(...)
lhTarget:BUFFER-VALUE = lhSource:BUFFER-VALUE
..ETC..
.
lhQuery:GET-NEXT(NO-LOCK).
END.
BUFFER-COPY Method
This method copies any common fields, determined by name, data type, and extent-matching, from the source buffer, source-buffer-handle, to the receiving buffer, bh, the object the method is applied to. If there are fields in one buffer that do not exist in the other, they are ignored. This method is used to accommodate temp-tables of joins.
Return Type: LOGICAL
Applies To: Buffer Object Handle
SYNTAX
bh:BUFFER-COPY( source-buffer-handle [ , except-list [ , pairs-list ] ] )
source-buffer-handle
An expression that evaluates to the source buffer handle.
except-list
A character expression that evaluates to a comma-separated list of field names to be excluded from the copy.
pairs-list
A character expression that evaluates to a comma-separated list of field-name pairs to be copied.
NOTE: The order within each field-name pair does not matter; each pair must contain one field name from the source and one field name from the target.
The following example fragment copies the customer table to the buffer, bh, except that customer.sales-rep is copied to a field called cust-sales-rep in the buffer:
bh:BUFFER-COPY(buffer customer:handle,?,"cust-sales-rep,sales-rep").