Kbase P131104: Record is not available outside the scope when used BY clause with FOR FIRST against OE Database but
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  4/10/2009 |
|
Status: Unverified
SYMPTOM(s):
Record is not available outside the scope when used BY clause with FOR FIRST against OE Database but available with DataServer
FACT(s) (Environment):
Record is not available outside the scope when used BY clause with FOR FIRST against OE Database
Record is available outside the scope when used BY clause with FOR FIRST against MS SQL Server DataServer
Record is available outside the scope when used BY clause with FOR FIRST against Oracle DataServer
Record is available outside the scope when used BY clause with FOR FIRST against ODBC DataServer
Progress/OpenEdge Versions
All Supported Operating Systems
CAUSE:
In the ABL, beyond the end of a FOR EACH, a record may or may not be available depending on whether or not you were sorting, and whether the sort involved an index, or a break by or, in this case, a DataServer. In general, the record is NOT available.
The rule is that you should never assume you have a record available after a FOR EACH unless you did a LEAVE out of the FOR EACH. So do a FIND LAST or whatever you need to do to get back the last record - if you use BREAK BY, you can use the LAST-OF function to determine which is the last record from inside the FOR EACH, and then do a LEAVE which will guarantee that the record is available outside the FOR EACH.
FIX:
Use LEAVE before the END of FOR block.