Use shorthand syntax for dynamic field and table references
- Last Updated: October 15, 2024
- 2 minute read
- OpenEdge
- Version 12.8
- Documentation
As you might have noticed in the previous section, the syntax for referring to dynamic fields
and tables within a temp-table (or dynamic ProDataSet, query, or buffer) is cumbersome.
For example, when you want to refer to the
CustNum field of the
ttCustomer table through a temp-table handle, you must type out
this long line of code:
|
There is an alternative shorthand syntax that you can use that can makes writing dynamic
references to fields and tables easier. You can use this shorthand syntax when the field
or table name you are referencing is known at compile time:
Where container-handle is a temp-table, ProDataSet, or
buffer handle and named-member is the name of a member of the
container. If the container is a temp-table, then the named-member
must be a field in the temp-table and the value of that field in the default buffer for
the temp-table is returned. If the container is a ProDataSet, then the
named-member must be the name of a buffer in the ProDataSet and
that buffer’s handle is returned. If the container is a buffer, then the
|
named-member must be a field in the buffer and the value of that
field in the buffer is returned.As an example, if the
CustNum field is known at compile time, you can
instead type the following code to reference the CustNum field of the
ttCustomer table through a temp-table handle:
|
The shorthand syntax uses a double colon (::) for the delimiter between
the two character strings to help avoid confusion with variables, text strings, as well
as static references to database tables and fields. The following table describes the
rules that determine which type of delimiter to use between two character strings.
|
If the left-side character string is ... |
If the right-side character string is ... |
Use this delimiter |
Examples |
|---|---|---|---|
All of the following:
|
A member of the left-side handle | A period (.) |
|
| A handle (not the actual name of a database or table) | An attribute or method for the left-side handle | A colon (:) |
|
|
A handle to a container object (buffer, table, or ProDataSet) |
Not an attribute or method, but is instead a named member of the left-side handle which is known at compile time | A double colon (::) |
|