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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Initial Programming Considerations<br />

Cursors<br />

2–48<br />

A cursor is like a pointer that points to consecutive records in a table. The ABL uses cursors to<br />

keep track of where it is in a table; <strong>for</strong> example, when it processes FOR EACH statements. Suppose<br />

that you are reading records from the customer table using the custnum index, and your current<br />

record is customer number 50. This means that ABL has a cursor positioned at custnum 50.<br />

Note that ABL maintains cursor positioning across queries.<br />

The <strong>Data</strong><strong>Server</strong> allows applications that access MS <strong>SQL</strong> <strong>Server</strong> data sources to imitate<br />

<strong>OpenEdge</strong> cursor behavior <strong>for</strong> FIND cursors. FOR EACH and OPEN QUERY statements do not retain<br />

cursor position across other queries or against a FIND statement.<br />

This section discusses the following cursor-related activities:<br />

• Forward and backward scrolling<br />

• Block cursors<br />

For details about firehose and fast <strong>for</strong>ward-only cursors, see the “Firehose and Fast<br />

Forward-Only Cursors” section on page 4–5.<br />

Forward and backward scrolling<br />

A query is scrolling if you specify SCROLLING in the DEFINE QUERY statement or if you define a<br />

browse <strong>for</strong> the query. You can use the REPOSITION statement to change your current position<br />

with the result set. For a non-scrolling query, the <strong>Data</strong><strong>Server</strong> allows you to only move<br />

sequentially <strong>for</strong>ward through the rows by using the FIRST and options of the GET statement.<br />

Scrolling basically means that the result set is cached on the client <strong>for</strong> backward and <strong>for</strong>ward<br />

scrolling.<br />

With the <strong>Data</strong><strong>Server</strong>, <strong>for</strong>ward and backward scrolling works with a MS <strong>SQL</strong> <strong>Server</strong> just as it<br />

does with an <strong>OpenEdge</strong> database except when the data source fails to find a record. In ABL, the<br />

cursor position can change after a failed search; however, with the <strong>Data</strong><strong>Server</strong>, a failed search<br />

does not affect the cursor. For example, if a cursor is positioned at custnum 50 and a request <strong>for</strong><br />

the next customer from an <strong>OpenEdge</strong> table fails, the cursor moves to the next sequential record<br />

beyond custnum 50. The same failed request from a data source leaves the cursor at custnum 50.<br />

Your <strong>Data</strong><strong>Server</strong> applications should not assume a certain cursor position after a failed find.<br />

You can, however, still use the AVAILABLE function to determine whether a record is available.<br />

The AVAILABLE function behaves consistently whether it accesses an <strong>OpenEdge</strong> database or a<br />

MS <strong>SQL</strong> <strong>Server</strong> data source.

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

Saved successfully!

Ooh no, something went wrong!