Create a dynamic Data-Source
- Last Updated: February 11, 2026
- 2 minute read
- OpenEdge
- Version 13.0
- Documentation
Syntax
Because a ProDataSet and a Data-Source are independent objects, there is no need to create dynamic Data-Source objects for a dynamic ProDataSet. If you have static Data-Sources available, you can attach them to a dynamic ProDataSet handle just as easily as you can to a static ProDataSet handle. For example, you could have something in the way of a collection of static Data-Source definitions for a set of database tables, but have a procedure that assembled those tables in a variety of ways into various dynamic ProDataSets. The Data-Source definitions could be static, and the ProDataSet definition dynamic.
You can also create a dynamic Data-Source when you
need one. You can attach a dynamic Data-Source to either a static
or dynamic ProDataSet. The CREATE DATA-SOURCE statement
is used to create a dynamic Data-Source, as shown using this syntax:
|
Like other database objects, the dynamic Data-Source
is created in the closest unnamed widget-pool unless the IN WIDGET-POOL phrase
is used. It is automatically deleted when the widget-pool is deleted.
If there is no WIDGET-POOL phrase and no local CREATE
WIDGET-POOL statement, then it will go into the session's
unnamed widget pool. In this latter case, it must be deleted specifically,
using the DELETE OBJECT statement. By contrast,
a static Data-Source is automatically deleted when the procedure
it is defined in is destroyed.
When you create a dynamic Data-Source,
you get a handle and an empty structure to fill in. You can then
associate a query with the dynamic Data-Source by setting its QUERY attribute,
as shown in the following syntax:
|
To disassociate the query and Data-Source, set
the QUERY attribute to the Unknown value (?),
as shown in the following syntax:
|
Just like a static Data-Source, a dynamic Data-Source must have a set of buffers that can be deduced from the query, or you can supply them separately from the query.
The ADD-SOURCE-BUFFER method
lets you build up a Data-Source at run time. This is the syntax
for the ADD-SOURCE-BUFFER method:
|
In this method:
- buffer-handle is the handle of a database buffer, or a temp-table buffer that you want to use as a Data-Source for a temp-table in a ProDataSet.
-
key-fields is a character expression that
evaluates to a comma-separated list of key component fields for
finding a record using the buffer, just as in the
KEYSphrase in the staticDEFINE DATA-SOURCEstatement. This argument can be passed as theUnknown value (?)when the AVM can deduce a unique primary key based on the index definitions for the table, or when the Data-Source will not be used for updates, and therefore a unique key is not needed.
As with ProDataSets,
you cannot use the ADD-SOURCE-BUFFER method to
add a buffer to a static Data-Source dynamically. The DEFINE
DATA-SOURCE statement must contain the complete definition
of the static Data-Source.