General information
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
CursorAdapter Insert Failure
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
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only