Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
CA update conflict handler problem
Message
De
31/12/2004 14:44:38
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Divers
Thread ID:
00973489
Message ID:
00973570
Vues:
19
Hi Marcel,

>So, any ideas. Can anyone reproduce this problem?
>

You should post COMPLETE repro code (the code that can be executed) accompanied with description of the result and what is wrong with it. You can use the following code as an example. BTW, the code produces expected result and the CursorAdapter object doesn't lock up. Also, for update conflict tracking, you can use ConflictCheckType property instead of throwing the error manually.

The code:
SET MULTILOCKS ON
CLEAR
?VERSION()

CREATE CURSOR foo (f1 I, f2  I)
INSERT INTO foo VALUES (-1,-1)
INSERT INTO foo VALUES (1,1)
INSERT INTO foo VALUES (2,2)
INSERT INTO foo VALUES (3,3)

LIST

LOCAL oCA as CursorAdapter

oCA=CREATEOBJECT("TestError")
oCA.Alias="Test"
oCA.DataSourceType="NATIVE"
oCA.SelectCmd="select * from foo"
oCA.KeyFieldList="f1"
oCA.UpdatableFieldList="f1, f2"
oCA.Tables="foo"
oCA.UpdateNameList="f1 foo.f1, f2 foo.f2"
oCA.BufferModeOverride= 5
*oCA.ConflictCheckType= 3

?oCA.CursorFill()

UPDATE foo SET f1=11 WHERE f1=1

SELECT test
replace f2 WITH f2*10 ALL 

IF !TABLEUPDATE(.T.,.T.,"test") &&,cErr)
	AERROR(aerrs)
	DISPLAY MEMORY LIKE aerrs
	&&DISPLAY MEMORY LIKE cErr

	SELECT foo
	LIST
	
	SELECT test
	GO 2
	?TABLEUPDATE(.F.)
	GO 3
	?TABLEUPDATE(.F.)
	GO 4
	?TABLEUPDATE(.F.)
	
	TABLEREVERT(.T.)
ENDIF 

SELECT foo
LIST
?"Done"


DEFINE CLASS TestError AS CursorAdapter

	FUNCTION AfterUpdate(cFldState, lForce, nUpdateType, cUpdateInsertCmd, cDeleteCmd, lResult)
		? PROGRAM(),[RECNO('test')=],RECNO('test')
		IF _TALLY=0 AND lResult
			ERROR "Update conflict"
		ENDIF 
	ENDfunc

ENDDEFINE
The result:
Visual FoxPro 08.00.0000.3117 for Windows
Record#           F1          F2
      1           -1          -1
      2            1           1
      3            2           2
      4            3           3

.T.
TESTERROR.AFTERUPDATE RECNO('test')=          1
TESTERROR.AFTERUPDATE RECNO('test')=          2
AERRS       Priv   A  5um4009a
   (   1,   1)     N  1098        (      1098.00000000)
   (   1,   2)     C  "Update conflict"
   (   1,   3)     C  .NULL.
   (   1,   4)     C  .NULL.
   (   1,   5)     C  .NULL.
   (   1,   6)     C  .NULL.
   (   1,   7)     C  .NULL.
Record#           F1          F2
      1           -1         -10
      2           11           1
      3            2           2
      4            3           3


TESTERROR.AFTERUPDATE RECNO('test')=          2.F.

TESTERROR.AFTERUPDATE RECNO('test')=          3.T.

TESTERROR.AFTERUPDATE RECNO('test')=          4.T.
Record#           F1          F2
      1           -1         -10
      2           11           1
      3            2          20
      4            3          30

Done
Thanks,
Aleksey.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform