This example uses a handle to a static buffer to illustrate how to use buffer attributes and methods, because the table name is known. You could also create a dynamic buffer for the table like this:
CREATE BUFFER hBuffer FOR TABLE "Customer".

Given that the table name is known and that it is, therefore, a literal in the CREATE BUFFER statement, there is no particular advantage to doing this. The CREATE BUFFER statement is better used when the buffer name is variable.

When you create dynamic buffers, rather than just using handles to static buffers, you need to delete them when you’re done using them, just as with other objects. You use the same DELETE OBJECT statement to do this.

Often you will want to delete dynamic buffers along with the dynamic query that uses them. You can use the GET-BUFFER-HANDLE method to determine what buffers to delete when you have finished with a dynamic query with dynamic buffers, as in this example:
/* Procedure h-cleanup.p -- shows how to delete
  a dynamic query and its dynamic buffers. */

VAR HANDLE hQuery.
VAR HANDLE hBuffer.

/* A list of tables for the dynamic query comes in as a parameter
  or is determined at run time. This simulates the list of names. */
VAR CHARACTER cBufNames = "Customer,Order,SalesRep".

VAR INTEGER iBufNum.
VAR CHARACTER cBufHandles.

/* CREATE a dynamic query and dynamic buffers for each table.
  Add each buffer to the query. */
CREATE QUERY hQuery.

DO iBufNum = 1 TO NUM-ENTRIES(cBufNames):
  CREATE BUFFER hBuffer FOR TABLE ENTRY(iBufNum, cBufNames).
  hQuery:ADD-BUFFER(hBuffer).
END.

/* Verify that the query has the buffers we created. */
cBufNames = "".
DO iBufNum = 1 TO hQuery:NUM-BUFFERS:
  cBufNames = cBufNames + hQuery:GET-BUFFER-HANDLE(iBufNum):NAME
    + " ".
END.
MESSAGE "This query uses buffers " cBufNames VIEW-AS ALERT-BOX.

/* Application code here uses the dynamic query and its buffers... */

/* When you're done with the query, build up a list of its buffers. */
DO iBufNum = 1 TO hQuery:NUM-BUFFERS:
  cBufHandles = cBufHandles +
    (IF cBufHandles = "" THEN "" ELSE ",") +
    STRING(hQuery:GET-BUFFER-HANDLE(iBufNum)).
END.
MESSAGE "Buffer handles are: " cBufHandles VIEW-AS ALERT-BOX.

/* After building the list, delete the buffers and then the query. */
DO iBufNum = 1 TO hQuery:NUM-BUFFERS:
  DELETE OBJECT WIDGET-HANDLE(ENTRY(iBufNum, cBufHandles)).
END.
DELETE OBJECT hQuery.

Note that you cannot delete the buffers in the loop where the code uses the GET-BUFFER-HANDLE() method at the end of the procedure because deleting the buffers would un-prepare the query and cause it to lose the list of buffers before you had retrieved them all. Thus, you need to build a comma-separated list of buffer handles and walk through the list afterwards to delete the buffers, and then delete the query.