Взято с technet.navision.com
Do not test for [Recid > 0] - valid Recid's may be negative as well...
Testing if a database buffer is empty can be done using the Recid column. But a little care should be taken. This article explains how.
One way to determine if a select returned a record, is to test the RecId column. Some programmers - including experienced XAL programmers - does this by testing if the column is greater than zero:
if (myTable.Recid>0) // then blah, blah,...
Still, for large amounts of data, Recid values may exceed the upper limit of a signed 32-bit long. For such high values, the Recid's in Axapta appear as negative number, thus making the above X++ construction error prone. Instead use
if (myTable.Recid) // then blah, blah,...
or
if (myTable.Recid != 0) // then blah, blah,...
One exception for this rule is, when the Recid column has been used for an aggregation such as count:
select count(Recid) from myTable; if (myTable.Recid > 0) // then blah, blah,...
since the number of records is obviously not negative.
__________________
С уважением, Вячеслав.
|