progress-4glopenedgedynamicquery

Progress 4GL: Buffer handle attribute for all fields


I am fairly new to Progress and even newer to handles so apologies if I have missed anything obvious, I've looked online but am yet to find what I'm looking for.

I am running a dynamic query similar to the below, in this example after then query is run, the "age" field of the corrresponding record is displayed on screen, I understand how this is done from the buffer-field attribute-method, but my question is how do I display the entire record, is there an equivalent attribute method, or have I misunderstood something crucial?. Thank you for your time. :

def var tbl as character no-undo.
def var fld as character no-undo.
def var qh as handle no-undo.
def var bh as handle no-undo.
def var fh as handle no-undo.

assign tbl = "customer".
assign fld = "age".
create buffer bh for table tbl.
create query qh.
qh:set-buffers( bh ).
qh:query-prepare( "for each " + tbl + " where name = 'tom'" ).
qh:query-open.

do transaction:
    qh:get-first( no-lock ).
    fh = bh:buffer-field( fld ).
    display fh:buffer-value.
end.

delete object bh.
delete object qh

Solution

  • There's no "easy" way to display the entire record in one statement the way you can with a static "DISPLAY table-name" statement. You can get the count of fields (buffer-handle:NUM-FIELDS) and then step through the individual fields and display their values using

    DO i = 1 to bh:NUM-FIELDS: 
         DISPLAY bh:BUFFER-FIELD(i):BUFFER-VALUE WITH DOWN.
         DOWN.
    END.