OpenEdge Data Management: DataServer for Microsoft SQL Server
OpenEdge Data Management: DataServer for Microsoft SQL Server
OpenEdge Data Management: DataServer for Microsoft SQL Server
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Chapter 2: Initial Programming Considerations<br />
USE-INDEX and BY clause considerations<br />
The BY clause offers greater programming flexibility than the USE-INDEX clause, and<br />
should be used in most cases. If indexes are added or deleted, applications coded with<br />
the BY clause only require a recompile to adjust to the index changes. Applications<br />
coded with the USE-INDEX clause require code modifications to be current with the<br />
index changes. If the index specified by a USE-INDEX clause is dropped, the code will<br />
fail to compile until the code is modified. If there is a more efficient index than the one<br />
specified in the USE-INDEX clause, it will not be selected by ABL and it is unlikely to be<br />
used in the data source’s query plan.<br />
Dummy indexes <strong>for</strong> sort order<br />
You can add dummy index definitions to your schema holder independent of the actual<br />
index definitions in your MS <strong>SQL</strong> <strong>Server</strong> data source to provide a sort order. These<br />
dummy indexes can improve the readability of your ABL code. An index in the schema<br />
holder need not match an index in the MS <strong>SQL</strong> <strong>Server</strong> data source. However, the<br />
absence of an index definition in the data source can impact per<strong>for</strong>mance when you<br />
retrieve data with selection on the dummy indexes.<br />
Unique indexes<br />
If your MS <strong>SQL</strong> <strong>Server</strong> data source tables have at least one unique index, they can be<br />
used to support operations such as backward and <strong>for</strong>ward scrolling and accurate<br />
cursor positioning through the FIND CURRENT, PREV, and LAST statements. If a table<br />
does not have a unique index, you can only scroll <strong>for</strong>ward through its data.<br />
If a MS <strong>SQL</strong> <strong>Server</strong> data source table does not have a unique index, you can designate<br />
an index to serve as the unique index <strong>for</strong> the schema holder. An index that you<br />
designate as unique in the schema holder must be unique with respect to the data in<br />
the data source, otherwise you receive runtime errors. See Chapter 7, “The <strong>Data</strong><strong>Server</strong><br />
Tutorial,” <strong>for</strong> instructions on using the <strong>Data</strong> Dictionary to designate unique indexes.<br />
MS <strong>SQL</strong> <strong>Server</strong> data source views and result sets from stored procedures do not have<br />
unique indexes. Just as <strong>for</strong> tables, you can use the <strong>Data</strong> Dictionary to create a unique<br />
index in the schema holder based on fields in a view or result set so that you can<br />
browse data accessed through views or stored procedures. For more in<strong>for</strong>mation about<br />
views, see the “MS <strong>SQL</strong> <strong>Server</strong> data source views” section on page 68.<br />
Note: Do not change the designated ROWID key of a record while an application is<br />
running. Suppose, <strong>for</strong> example, that custnum is a unique key and has been<br />
designated the <strong>OpenEdge</strong> ROWID. If a user changes the value of custnum <strong>for</strong> a<br />
customer from 1 to 111, other users receive an error message when they try<br />
to access the record <strong>for</strong> customer 1.<br />
Large key entry support<br />
Updates in the <strong>OpenEdge</strong> database enable existing index key limits, currently set at<br />
approximately 200 bytes, to be widened. For example, this enhancement will enable<br />
databases with a block size of 4K or 8K to support a maximum index key of<br />
approximately 2000 bytes. Also, the index key width expansion extends the maximum<br />
key size supported in the <strong>OpenEdge</strong> client that can be used with databases exported<br />
to <strong>for</strong>eign data sources.<br />
When you are migrating <strong>OpenEdge</strong> keys to a <strong>for</strong>eign data source, the key sizes cannot<br />
be larger than those supported by the <strong>for</strong>eign data source. Because the maximum<br />
<strong>OpenEdge</strong> key size is data-source dependent, you should consider your target data<br />
66 <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>