13.01.2013 Views

OpenEdge Data Management: DataServer for Microsoft SQL Server

OpenEdge Data Management: DataServer for Microsoft SQL Server

OpenEdge Data Management: DataServer for Microsoft SQL Server

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

For example, the following statement returns the same results <strong>for</strong> an <strong>OpenEdge</strong><br />

database and a MS <strong>SQL</strong> <strong>Server</strong> data source:<br />

DEFINE QUERY myquery FOR customer FIELDS (custnum name) SCROLLING.<br />

OPEN QUERY myquery FOR EACH customer NO-LOCK WHERE custnum LT 6<br />

BY customer.name.<br />

ABL issues<br />

Include the SCROLLING option to enable GET PREVIOUS. You must include the NO–LOCK<br />

option when you open queries that are defined with field lists.<br />

Similarly, you must include the NO–LOCK option in FOR EACH statements that include field<br />

lists, as in the following example:<br />

FOR EACH customer FIELDS (cust_num name) NO-LOCK:<br />

Field lists are effective only when you also specify the NO–LOCK option. This option<br />

ensures that the <strong>Data</strong><strong>Server</strong> does not have to refetch rows, which can slow<br />

per<strong>for</strong>mance. If a lock upgrade is required, the field list is ignored and all fields are<br />

retrieved.<br />

Use field lists to retrieve only those fields that your application requires. For<br />

per<strong>for</strong>mance reasons, the <strong>Data</strong><strong>Server</strong> retrieves the first index field even if you do not<br />

include it in the field list. In cases where the <strong>Data</strong><strong>Server</strong> can predict that a query will<br />

require a refetch, it retrieves the entire record. The <strong>Data</strong><strong>Server</strong> allocates memory<br />

based on the maximum size defined <strong>for</strong> a field in a record. Omitting larger fields from a<br />

query can enhance per<strong>for</strong>mance. In addition, combining lookahead cursors and field<br />

lists greatly improves a query’s per<strong>for</strong>mance.<br />

When you specify a field that has an extent, the query returns the entire array.<br />

When the <strong>Data</strong><strong>Server</strong> processes a query with a field list, it caches the fields that are<br />

part of the field list and any other fields that the query specified, which you can then<br />

access without making another call to the data source. For example, the <strong>Data</strong><strong>Server</strong><br />

fetches the name and the postalcode field to process the following query:<br />

FOR EACH customer FIELDS (name) WHERE customer.postalcode EQ 01730 NO-LOCK:<br />

Note: Cached fields might have per<strong>for</strong>mance implications if you modify the record<br />

later, as the <strong>Data</strong><strong>Server</strong> must refetch the record to place a lock on it.<br />

If you specify a field list in a join, you might have to adjust the cache size <strong>for</strong> lookahead<br />

cursors, either with the CACHE–SIZE option in a QUERY–TUNING phrase or at the session<br />

level with the -Dsrv qt_cache_size startup parameter.<br />

Any per<strong>for</strong>mance gained through field lists is lost if you use nonlookahead cursors.<br />

Lookahead and block cursors gain per<strong>for</strong>mance by prebinding the fields of your result<br />

set. For maximum efficiency, any text or image fields should be explicitly excluded from<br />

your field list if possible because MS <strong>SQL</strong> <strong>Server</strong> does not allow those fields to be<br />

pre-bound.<br />

<strong>OpenEdge</strong> <strong>Data</strong> <strong>Management</strong>: <strong>Data</strong><strong>Server</strong> <strong>for</strong> <strong>Microsoft</strong> <strong>SQL</strong> <strong>Server</strong> 113

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!