Data Access Worldwide Knowledge Base

Article ID 2268
Article Title INFO: Reread clears the record buffer if the record was not active
Article URL http://www.dataaccess.com/kbasepublic/KBPrint.asp?ArticleID=2268
KBase Category VDF11
Date Created 11/29/2006
Last Edit Date 12/08/2006


Article Text
PROBLEM:
I noticed a difference between Visual DataFlex 7 and Visual DataFlex 11.1.

My code contains the following structure:

    Open <Table>
    Clear <Table>
    Move <SomeValue> To <Table>.<SomeColumn>
    Find Eq <Table>.<SomeColumn>
    Reread <Table>
        Move (<Table>.<SomeOtherColumn> + 1) To <Table>.<SomeOtherColumn>
        Saverecord <Table>
    Unlock        

When the record was not found in the above case under VDF7 the <SomeValue> was kept in <Table>.<SomeColumn> and the save made a new record with the <SomeValue> in the column <SomeColumn>. In VDF11.1 the value in <Table>.<SomeColumn> is cleared by the REREAD command.

EXPLANATION:
The change is intentional. At low level, the REREAD performs a FindByRowId. If the FindByRowID does not find a record, it clears the buffer.

The code structure shown above is wrong (and has always been wrong). You should not rely on odd behavior to create records.

NOTE: Without <Table> in REREAD <Table> the behavior is again different because REREAD without table arguments only refinds records in active buffers and this is not one of them.

The correct code should be:

    Clear <Table>
    Move <SomeValue> To <Table>.<SomeColumn>
    Find Eq <Table>.<SomeColumn>

    If (Found) Reread <Table>
    Else Lock

    Move (<Table>.<SomeOtherColumn> + 1) To <Table>.<SomeOtherColumn>
    Saverecord <Table>
    Unlock      

      


Contributed By:
Vincent Oorsprong
Company: Data Access Worldwide
email: vincent.oorsprong@dataaccess.eu
Web Site: http://www.dataaccess.eu


Email this Article
Email this Article to a Colleague
Send Feedback on this Article to Data Access Worldwide
Copyright ©2010 Data Access Corporation. All rights reserved.

The information provided in the Data Access Technical Knowledge Base is provided "as is" without warranty of any kind. Data Access Corporation disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. In no event shall Data Access Corporation or its suppliers be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages, even if Data Access Corporation or its suppliers have been advised of the possibility of such damages. Some states do not allow the exclusion or limitation of liability for consequential or incidental damages so the foregoing limitation may not apply.