Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
New to VFP buffering.
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00053915
Message ID:
00054070
Views:
41
Darren,

Thanks for responding. My question was really directed towards scanning through a table and adding records or replacing field data (see original code I sent). Could you (or anyone) please send me code examples of how to add records/replace existing field data in the following situations.

1. A table opened inside a form's DE:

For example, should I set the table for table buffering and perform the following?:

SELECT table
FOR nCtr = 1 to ALEN(dataarray,1)
IF SEEK(value)
REPLACE field1 WITH dataarray(nCtr,1)
REPLACE field2 WITH dataarray(nCtr,2)
REPLACE filed3 WITH dataarray(nCtr,3)
ELSE
INSERT INTO table field1,field2,field3 VALUES ;
dataarray(nCtr,1),dataarray(nCtr,2),dataarray(nCtr,3)
ENDIF
ENDFOR
IF NOT TABLEUPDATE(.T.)
*** Error message
ENDIF


2. A table opened outside a form's DE (within a program).

Should I use explicit locking in this case:

SELECT table
FOR nCtr = 1 to ALEN(dataarray,1)
IF SEEK(value)
IF RLOCK()
REPLACE field1 WITH dataarray(nCtr,1)
REPLACE field2 WITH dataarray(nCtr,2)
REPLACE filed3 WITH dataarray(nCtr,3)
UNLOCK()

ELSE
INSERT INTO table field1,field2,field3 VALUES ;
dataarray(nCtr,1),dataarray(nCtr,2),dataarray(nCtr,3)
ENDIF
ENDFOR


Any help would be greatly appreciated! I want to make sure I do the right thing. Thanks.


>>Hi,
>
>I'm fairly new to VFP and had a question regarding buffering, so I thought I would ask the experts out there. I have a table in form's DE and have it set to use the forms default buffering. The form is set to 2 - Optimistic buffering. I have a push button on the form that populates the table with data from an array. What method do I use:
>>
>>Do I use my old FP2.6 code:
>>
>>SELECT table
>>FOR nCtr = 1 TO ALEN(Array,1)
>> IF SEEK(array(nCtr)
>> IF RLOCK()
>> REPLACE field1 WITH array(nCtr,1)
>> REPLACE field2 WITH array(nCtr,2)
>> UNLOCK
>> ENDIF
>> ELSE
>> APPEND BLANK
>> REPLACE field1 WITH array(nCtr,1)
>> REPLACE field2 WITH array(nCtr,2)
>> UNLOCK
>> ENDIF
>>ENDFOR
>>
>>or.......
>>
>>Can I use the following:
>>
>>SELECT table
>>FOR nCtr = 1 TO ALEN(Array,1)
>> IF SEEK(array(nCtr)
>> REPLACE field1 WITH array(nCtr,1)
>> REPLACE field2 WITH array(nCtr,2)
>> ELSE
>> APPEND BLANK
>> REPLACE field1 WITH array(nCtr,1)
>> REPLACE field2 WITH array(nCtr,2)
>> ENDIF
>>ENDFOR
>>TABLEUPDATE(.T.)
>>
>>Also, would using a INSERT-SQL statement be preferable over APPEND BLANK in the above example? Would I still issue a TABLEUPDATE(.T.) at the end if I did?
>>
>>One more thing, I have seen the following used: TABLEUPDATE(.T.,.T.) In help, I could only find one logical parameter to pass. What are these parameters used for?
>>
>>TIA for any expert advise!
>>
>>James Moore
>
>Some thoughts:
>
>I never use the explicit locking commands, FoxPro handles that automatically for all my purposes.
>
>Use INSERT-SQL - it's faster, because it updates the indexes once, while APPEND BLANK does it twice.
>
>The second TABLEUPDATE parameter is lForce, which will forcably overwrite changes made by another network user.
>
>Optimistic buffering is faster, fine for most situations; use row buffering for parent tables, table buffering for children.
>
>HTH
James Moore
Owner/Developer
Ministry Tracking Software, Inc.
www.youthtrack.com
Previous
Reply
Map
View

Click here to load this message in the networking platform