Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
CursorAdapter Insert Failure
Message
From
23/06/2006 12:19:03
Jarid Griesel
The Innovix Technology Group (Pty) Ltd
Johannesburg, South Africa
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
CursorAdapter Insert Failure
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01131208
Message ID:
01131208
Views:
176
Hi All

I have a simple CA object using NATIVE tables
When I INSERT a row into the cursor and call TableUpdate, TABLEUPDATE fails with error 2166 ("The refresh key for the table myBaseTable is not found") even though the new record is propogated into the base table.

Calling TableUpdate again returns .T., but now the new record is duplicated in the base table.

The code to replicate the error is attatched below

TIA


**> create the base table
CREATE TABLE caudclv2 (lv1code C(3), lv2code C(4), descr C(40))
INDEX ON lv1code + lv2code TAG "prikey"

**> define property values
pcKeyLst = "lv1code, lv2code"
pcFldLst = "lv1code, lv2code, descr"
pcDST = "NATIVE"

**> create the cursor adapter
poCA = CREATEOBJECT("CursorAdapter")
WITH poCA
.Alias = "c_caudclv2"
.AllowDelete = .T.
.AllowInsert = .T.
.AllowUpdate = .T.
.BufferModeOverride = 3
.CursorSchema = "lv1code C(3), lv2code C(4), descr C(40)"
.DataSourceType = pcDST
.DeleteCmdDataSourceType = pcDST
.InsertCmdDataSourceType = pcDST
.InsertCmdRefreshFieldList = pcFldLst
.InsertCmdRefreshKeyFieldList = pcKeyLst
.KeyFieldList = pcKeyLst
.RefreshCmdDataSourceType = pcDST
.RefreshIgnoreFieldList = ""
.SelectCmd = "SELECT * FROM caudclv2"
.SendUpdates = .T.
.Tables = "caudclv2"
.UpdateCmdRefreshFieldList = pcFldLst
.UpdateCmdRefreshKeyFieldList = pcKeyLst
.UpdateCmdDataSourceType = pcDST
.UpdatableFieldList = pcFldLst
.UpdateNameList = "lv1code caudclv2.lv1code, lv2code caudclv2.lv2code, " + ;
"descr caudclv2.descr"
.UseCursorSchema = .T.
.WhereType = 3
ENDWITH

SET STEP ON

**> now run the cursor adapter and insert a record
CLEAR
CLEAR ERROR
? poCA.CurSorFill()
INSERT INTO "c_caudclv2" VALUES ("ADD", "ABC", "mary")
? RECCOUNT("c_caudclv2") && ca cursor
? RECCOUNT("caudclv2") && base table

IF TABLEUPDATE(0, .F., "c_caudclv2") = .F.
**> this always fails with error code 2166 -
**> "The refresh key for table caudclv2 is not found"
= AERROR(paErr)
LIST MEMORY LIKE paErr
ENDIF

? RECCOUNT("c_caudclv2") && ca cursor
? RECCOUNT("caudclv2") && base table

**> issuing table update again will succede ( it would seem because the base
**> table now has the record in it, how ever the second tableupdate command
**> duplicates the record in the data source table
? TABLEUPDATE(0, .F., "c_caudclv2")
? RECCOUNT("c_caudclv2") && ca cursor
? RECCOUNT("caudclv2") && base table
Next
Reply
Map
View

Click here to load this message in the networking platform