>CLOSE DATABASES all >CLEAR >SET MULTILOCKS ON >SET NULL ON >?VERSION() >? >CREATE CURSOR test (f1 I NOT NULL, f2 I NOT NULL) > >LOCAL oCA as CursorAdapter > >oCA=CREATEOBJECT("CursorAdapter") >oCA.DataSourceType="NATIVE" >oCA.SelectCmd="SELECT f1 FROM test" >oCA.UpdatableFieldList="f1" >oCA.Tables="test" >oCA.UpdateNameList="f1 test.f1" >oCA.Alias="testCA" > >? "Reason #1: The field isn't selected from the table" >?oCA.CursorFill() >SELECT testCA >APPEND BLANK >REPLACE f1 WITH 1 >IF !TABLEUPDATE() > AERROR(aerrs) > ?aerrs[1,2] > TABLEREVERT() >ENDIF >? >? "Reason #2: The field isn't included into UpdatableFieldList and/or UpdateNameList" >oCA.SelectCmd="SELECT f1,f2 FROM test" >?oCA.CursorFill() >SELECT testCA >INSERT INTO testCA VALUES (2,2) >IF !TABLEUPDATE() > AERROR(aerrs) > ?aerrs[1,2] >ELSE > ? "Unexpected." >ENDIF >?"Let's include it: " >oCA.UpdatableFieldList="f1, f2" >oCA.UpdateNameList="f1 test.f1, f2 test.f2" >IF !TABLEUPDATE() > AERROR(aerrs) > ??aerrs[1,2] > TABLEREVERT() >ELSE > ?? "TABLEUPDATE succeeded" >ENDIF >? >? "Reason #3: The field isn't modified" >SET NULL OFF >INSERT INTO testCA (f1) VALUES (3) >SET NULL ON >IF !TABLEUPDATE() > AERROR(aerrs) > ?aerrs[1,2] >ELSE > ? "Unexpected." >ENDIF >? "Let's modify the field: " >REPLACE f2 WITH 3 >IF !TABLEUPDATE() > AERROR(aerrs) > ??aerrs[1,2] > TABLEREVERT() >ELSE > ?? "TABLEUPDATE succeeded" >ENDIF >? "Let's use DEFAULT value: " >oCA.CursorSchema = "f1 I, f2 I DEFAULT 4" >oCA.CursorFill(.T.) >SELECT testCA >SET NULL OFF >INSERT INTO testCA (f1) VALUES (4) >SET NULL ON >IF !TABLEUPDATE() > AERROR(aerrs) > ??aerrs[1,2] > TABLEREVERT() >ELSE > ?? "TABLEUPDATE succeeded" >ENDIF >? >TABLEREVERT() >?ALIAS() >LIST >? >SELECT test >?ALIAS() >LIST >>
> >Visual FoxPro 09.00.0000.3504 for Windows > >Reason #1: The field isn't selected from the table >.T. >Field F2 does not accept null values. > >Reason #2: The field isn't included into UpdatableFieldList and/or UpdateNameList >.T. >Field F2 does not accept null values. >Let's include it: TABLEUPDATE succeeded > >Reason #3: The field isn't modified >Field F2 does not accept null values. >Let's modify the field: TABLEUPDATE succeeded >Let's use DEFAULT value: TABLEUPDATE succeeded > >TESTCA >Record# F1 F2 > 1 2 2 > 2 3 3 > 3 4 4 > > >TEST >Record# F1 F2 > 1 2 2 > 2 3 3 > 3 4 4 >