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 />

2–56<br />

The following code will not return a run time error because the CAN-FIND expression resolves<br />

to FALSE, masking the fact that there was in fact no customer.st value to compare:<br />

FOR EACH customer FIELDS (custnum name)<br />

WHERE customer.name EQ "Off the Wall" NO-LOCK:<br />

CAN-FIND(FIRST order WHERE order.st = customer.st NO-LOCK).<br />

END.<br />

See the “Record Phrase” entry in <strong>OpenEdge</strong> Development: ABL Reference <strong>for</strong> more in<strong>for</strong>mation<br />

on the FIELDS option.<br />

FIND statements<br />

The <strong>Data</strong><strong>Server</strong> fully supports the FIND FIRST, CURRENT, LAST, PREV, and NEXT statements <strong>for</strong><br />

MS <strong>SQL</strong> <strong>Server</strong> data source tables that have unique indexes. If a table has no unique index, only<br />

the FIND FIRST and FIND NEXT statements are available <strong>for</strong> that table. The following section<br />

provides additional in<strong>for</strong>mation about specific FIND statements.<br />

FIND NEXT statement<br />

The FIND NEXT statement can generate different results with the <strong>Data</strong><strong>Server</strong> when compared to<br />

the same statement executed against an <strong>OpenEdge</strong> database. A FIND NEXT statement refers to a<br />

previous FIND statement only if the WHERE clauses of each statement are identical. If the WHERE<br />

clauses are different, or if one of the statements does not have a WHERE clause, the FIND NEXT will<br />

behave like a FIND FIRST statement.<br />

FIND PREV and FIND LAST statements<br />

Applications that use the FIND PREV or FIND LAST statements work on tables in a manner<br />

consistent with the <strong>OpenEdge</strong> database. The only exception occurs when the FIND PREV or FIND<br />

LAST statement fails. In <strong>OpenEdge</strong>, the cursor is located after the last record that was scanned.<br />

In the MS <strong>SQL</strong> <strong>Server</strong> data source, the cursor behaves as if the failed FIND had never occurred.<br />

To support these statements, a table must include support <strong>for</strong> the <strong>OpenEdge</strong> ROWID function<br />

(through either a PROGRESS_RECID column or an indexed NUMBER column with unique values).<br />

See the “ROWID function” section on page 2–52 <strong>for</strong> more in<strong>for</strong>mation.<br />

For example, the procedure find.p accesses <strong>OpenEdge</strong> and MS <strong>SQL</strong> <strong>Server</strong> databases using<br />

the same FIND and FIND PREV statements in each case, as shown:<br />

find.p<br />

/* This code accesses an <strong>OpenEdge</strong> database. */<br />

FIND demo.customer WHERE demo.customer.custnum EQ 3.<br />

FIND PREV demo.customer.<br />

DISPLAY demo.customer.custnum<br />

LABEL "PROGRESS DATABASE RESULT" WITH FRAME new-frame.<br />

/* This code accesses a MS <strong>SQL</strong> <strong>Server</strong> data source.*/<br />

FIND mssdemo.customer WHERE mssdemo.customer.custnum EQ 3.<br />

FIND PREV mssdemo.customer.<br />

DISPLAY mssdemo.customer.custnum<br />

LABEL "MSS DATA SOURCE RESULT" WITH COL 29.

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

Saved successfully!

Ooh no, something went wrong!