>>If you create a temporary cursor, you are the only one that accesses it. No need to LOCK(), or anything similar.
>
>If temporary cursor is related to tables and temporary cursor record is
>locked,
related tables are locked also in previous versions of foxpro.
>If related table has no data, it is locked at eof() position.
>In my sample, LOCK() is used to change VFP error to other message. If I remove lock(), I get a vfp error on REPLACE command since REPLACE tries to place lock.
The new, VFP, way, to handle this, is as follows:
Use buffering (usually, optimistic buffering is recommended).
Don't use rlock().
Instead, use TableUpdate(). Any required locks will be done automatically, "internally", by VFP.
Check the return value of TableUpdate().
If the return value is .F., use aerror() to gather error information.
These methods work both with tables and with buffers.
One big advantage of buffering is that you can also undo all changes to the current record - or even to several records! with TableRevert().
>If underlying table does not have unigue combination of fields, as invoice rows, it is impossible to update it using views. So i cannot use views.
That, I think, is by itself sufficient reason to have a primary key. If you don't have a field / fields that uniquely identifies / identify every record, you can create an "auto-incremented" 4-byte integer as the PK-field. "Auto-incremented" isn't natively supported by VFP, but you can easily call a function from the default value of the field.
>>>I cannot use TABLEUPDATE() since this is temporary cursor. I use this cursor to collect document rows.
>>>For saving document, I use COPY TO and TABLEREVERT()
???
If your temporary cursor has a structure like your table, you can load the empty cursor, add records, and then TableUpdate() to send the changes to the underlying table.
Or, when you copy records to the main table, you can still use buffering (on the main table), and test for TableUpdate().
Hilmar.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)