How You Can Populate a Dynamic Table Field
To populate a dynamic table field from a database table, use an SQLSelect object or a QueryObject object and point the target array of the query object to the array you declared for the table field.
For example, the DynamicQuery frame uses a query object to load a dynamically created table field at runtime. The code in this frame that retrieves the data from the database and displays it in a table field performs the following operations:
• Declares an array variable called tarray
• Establishes the values in the tarray array as:
– The array underlying the tbl table field
– The query object's TargetArray
• Opens a query object named qo in array mode, retrieving the data from the database
• Closes the query object
• Updates the form display, forcing display of data in tbl
The following code performs these operations:
declare
tarray = ArrayObject;
enddeclare
...
qo.TargetArray = tarray;
. . .
tfield.DeclareData(result = byref(tarray));
...
status = qo.Open(QueryMode = QY_ARRAY);
qo.Close();
field(tbl).UpdField();
Opening a query object in QY_ARRAY mode retrieves all the data directly from the database into the named array during the Open method invocation. (The Load and NextRow methods are not required to display the data on the form.) Because array mode eliminates intermediate steps in retrieving and displaying data, performance is better using array mode rather than cache, cursor, or direct modes.
For array mode, the class of the array being loaded must have attribute names matching the names of the columns in the query (the array attributes must match all columns whose IsSelectTarget attribute has been set to TRUE).
For more information about using SQLSelect and QueryObject objects, see
Creating Dynamic Frames.
Last modified date: 12/20/2023