General information
Category:
Databases,Tables, Views, Indexing and SQL syntax
I tried several times and worked fine all of them.
One question, did you tried using a primary key NOT made of 2 fields, only with one integer field? I tried that but it also runs with no error, as the previous one.
Why don't you try that?
Hernan
The following is your code but with an autoinc primary key, why don't you run it in your pc and see if it fails?
SET SAFETY OFF
CREATE TABLE caudclv2 (idcaudclv2 i autoinc, lv1code C(3), lv2code C(4), descr C(40))
INDEX ON lv1code + lv2code TAG "prikey"
SET SAFETY ON
**> define property values
pcKeyLst = "lv1code, lv2code"
pcFldLst = "idcaudclv2, 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 = "idcaudclv2 i, 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" (lv1code, lv2code, descr) 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
Previous
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