Dynamic Queries and arrays

jennil

New Member
I have used the following dynamic query to return all labels and field values for a specific table record. It works great, until I come across a field that is an array. The result of that scenario is an error and ? value returned. Does anyone know how to look for this instance and when found, display the values for each extent?

============================
DEF INPUT PARAM vTable AS CHAR.
DEF INPUT PARAM vRecid AS RECID.

DEFINE VAR vQuery AS CHAR.
DEFINE VAR i AS INT.
DEFINE VAR x AS INT.
DEFINE VAR vQuery_hdl AS HANDLE.
DEFINE VAR vBuffer_hdl AS HANDLE.
DEFINE VAR vField_hdl AS HANDLE.

CREATE QUERY vQuery_hdl.
CREATE BUFFER vBuffer_hdl FOR TABLE vTable.

vQuery = "for each " + vTable + " where recid(" + vTable + ") = " + string(vRecid).

vQuery_hdl:SET-BUFFERS(vBuffer_hdl).
vQuery_hdl:QUERY-PREPARE(vQuery).
vQuery_hdl:QUERY-OPEN().

do-loop:
DO WHILE TRUE:
vQuery_hdl:GET-NEXT().
IF vQuery_hdl:QUERY-OFF-END = TRUE THEN LEAVE do-loop.
x = vBuffer_hdl:num-fields.
REPEAT i = 1 TO x ON ENDKEY UNDO, LEAVE do-loop:
vField_hdl = vBuffer_hdl:BUFFER-FIELD(i) no-error.
DISPLAY vField_hdl:NAME + ":" FORMAT "x(10)"
vField_hdl:extent
vField_hdl:STRING-VALUE() FORMAT "x(20)"
WITH THREE-D USE-TEXT WIDTH 60.
END.
END.

delete object vBuffer_hdl.
delete object vquery_hdl.
=====================================

Thanks!
Jennifer Lammers
 
U

Unregistered

Guest
Hello,

The EXTENT-Attribute of the BUFFER-Field wild give you the number of extents!!
IT's ZERO for a Field with no extent!!

To display all the extents use vfield_hdl:STRING-VALUE[n].
n is the extent number you want to display!! becarefull Zero is not allowed!

Kind Regards

Ulf Bicker
Progress Software Germany
 
Top