Data Access Worldwide Knowledge Base
Article ID 2207 Article Title PROBLEM: Not all the data of my record is copied when I create a record copy Article URL http://www.dataaccess.com/kbasepublic/KBPrint.asp?ArticleID=2207 KBase Category VDF11 Date Created 01/20/2006 Last Edit Date 01/20/2006
Article Text
PROBLEM:
I started removing all RECNUM references in my program and replacing this with the ROWID programming technique. I heard the advise not to use "Move 0 To table.recnum" anymore when making a copy of a record and replace that syntax with "Set_Attribute DF_FILE_STATUS Of Table.File_Number To DF_FILE_INACTIVE" and implemented this as such. But now I notice that parts of the record stay without a value. Only the index field data is stored in the new record. Also weird to me is that when I move the value of one of the non-indexed fields to itself the record is correctly copied. What's wrong?
This is a piece of sample code based on the order entry samples:
Begin_transaction
Find Gt Customer By Index.1
Set_Attribute DF_FILE_STATUS Of Customer.File_Number To DF_FILE_INACTIVE
Move 88282 To Customer.Customer_number
Saverecord Customer
End_transaction
ANSWER:
Release of DataFlex 3.0 came with a new optimization feature. When all the data needed was already present in the index entry read, the record was not fetched from disk. Setting the file status to DF_FILE_INACTIVE does not currently fetch the record and you have to use one of the following solutions:
SOLUTION 1:
Move a field outside the indexed fields to itself. When the above code is changed to:
Begin_transaction
Find Gt Customer By Index.1
Move Customer.Credit_Limit To Customer.Credit_Limit
Set_Attribute DF_FILE_STATUS Of Customer.File_Number To DF_FILE_INACTIVE
Move 88282 To Customer.Customer_number
Saverecord Customer
End_transaction
The copy functions fine.
SOLUTION 2:
Disable the index optimization feature. This can be done by adding the following code:
Procedure TurnOffIndexOptimize DESKTOP
Integer iNull iStatus
String sNull
Call_Driver 0 "DATAFLEX" Function FLEX_SET_INDEX_OPT ;
Callback iNull ;
Passing sNull sNull FLEX_INDEX_OPT_OFF ;
Result iStatus
End_Procedure
Send TurnOffIndexOptimize
You can also use this last one in a bit more dynamic way by using code like:
Procedure OnClick
Integer iOrgCovering
Open Customer
Get IndexCovering To iOrgCovering
Set IndexCovering To FLEX_INDEX_OPT_OFF
Clear Customer
Move 1 To Customer.Customer_number
Find Eq Customer By 1
Begin_Transaction
Set_Attribute DF_FILE_STATUS Of Customer.File_number To DF_FILE_INACTIVE
Move 9999 To Customer.Customer_number
Saverecord Customer
End_Transaction
Set IndexCovering To iOrgCovering
End_Procedure // OnClick
Procedure Set IndexCovering Integer iCovering
String sVoid
Call_Driver 0 "DATAFLEX" Function FLEX_SET_INDEX_OPT ;
Callback 0 ;
Passing sVoid sVoid iCovering ;
Result iCovering
End_procedure // IndexCovering
Function IndexCovering Returns Integer
String sVoid
Integer iVoid
Integer iCovering
Call_Driver 0 "DATAFLEX" Function FLEX_GET_INDEX_OPT ;
Callback 0 ;
Passing sVoid sVoid iVoid ;
Result iCovering
Function_Return iCovering
End_Function // IndexCovering
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.