4

コードの可読性、柔軟性、およびコース外のパフォーマンスの観点から、OpenEdge のそれぞれの長所と短所を見てみましょう。

静的クエリ:

+   readability: convenient `buffer.field` notation
+   performance: higher (supposedly, need comments)
-/+ "global scope" allows to handle all previously used buffers, but could lead
                 to ambiguousness, so you'll have to clarify it with a table
                 name (table.field instead of field)
-   flexibility: you cannot alternate predicate-expression much,
                 even IF function is not recommended (can affect performance)      

動的クエリ:

+   flexibility: you can build predicate-expression completely runtime
+   flexibility: you can work with each field not specifying its name,
                 f.e. you can process all fields of certain record in cycle
+   flexibility: are reusable (need comments on this point)
+/- "local scope" allows to use only buffers specified in `SET-BUFFERS` method
-   readability: a little more code to write
-   performance: slightly slower (not sure)

追記・修正大歓迎です。関連する読み取りへのリンクも同様です。

4

1 に答える 1

4

A static query's filter condition can be changed "on the fly" like so:

DEFINE QUERY q-name FOR table-name.
DEFINE VARIABLE h-qry   AS HANDLE      NO-UNDO.
h-qry = QUERY q-name:HANDLE.
h-qry:QUERY-PREPARE("for each table-name where table-name.field-name = 1").

from here the query is treated the same as any normal static query.

readability: the "buffer-handle:buffer-field("field-name"):buffer-value" construct refers to dynamic buffers - it's perfectly acceptable to use static buffers in dynamic queries (via the BUFFER table-name:HANDLE), so dynamic query buffers can be used w/static buffers and it's not always necessary to de-reference a field using it's handle.

performance: last time I did a comparison, dynamic queries were slower than static queries for the same query condition. The upside is they're more flexible than static queries.

reusability: Once a dynamic query's buffer structure has been set, AFAIK, it can't be changed. It can be re-opened with a new filter condition same as a static query though.

于 2013-08-16T10:55:36.283 に答える