Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Triggers, CANNOT Update the Cursor err
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Triggers, CANNOT Update the Cursor err
Divers
Thread ID:
00806999
Message ID:
00806999
Vues:
43
ok here is the thing:

I am working in a rutine to update a memo field all my tables have named ChangedBy, I am storing some kind of transaction log into this memo field. Doind this by code in every form wouldn't be very intelligent so i decided to put a trigger in the Table for Update. everithing seems to work just fine. What I am doing is building a string with the name of the changed fields and its old and new value something like this

Changes made for the user USER1 are Field1 OldVal NewVal, Field2 oldVal NewVal

the problem occurs when i try to do a replace command, once the string is built the trigger should update the memo field with the changes made i do this
if !empty(lcString) then 
    replace myMemofield with myMemoField + lcString + chr(13) in myAlias
endif
then I got my err message, can not update the cursor, any ideas why?

here is the code just in case you guys want to have a hard time understanding my bloody logic
LPARAMETERS lcAction, lcAlias, lcFieldToUpdate

LOCAL lnFields
PUBLIC lcString
DO CASE 
	CASE lcAction = 'I'
	CASE lcAction = 'U'
		*:esta modificando el registro, entonces se deberan registrar todos 
		*:los posibles cambios que el usuario haya efectuado junto con el 
		*:numero de usuario, la computadora, la hora y fecha de la modificacion
		lnFields = FCOUNT(lcAlias)
		lcString = ''
		*:Se obtienen los valores antiguos y actuales de cada campo
		FOR _N =  1 TO lnFields
			_Pos = ALLTRIM(STR(_N)) 
			_FieldName  = '_FieldVar'  + _Pos
			_OldValue	= '_OldValVar' + _Pos
			_NewValue	= '_NewValVar' + _Pos
			&_FieldName = FIELD(_N)
			*:Convirtiendo cualquier tipo de dato que sea en caracter para poder unirlo con los demas
			_VariableNewValueType= TYPE(FIELD(_N))
			_FieldName2 = lcAlias + '.' + FIELD(_N)
			_VariableNewValue 	 = &_FieldName2
			*:Unicamente si es de tipo logico se cambia, de cualquier otro tipo se utiliza 
			*:el PADL para convertirlo a caracter
			Do Case
				Case _VariableNewValueType = [L]
					&_NewValue	 = IIF(_VariableNewValue,'.T.','.F.')
				OtherWise
					&_NewValue	 = ALLTRIM(PADL(_VariableNewValue,256))
			EndCase
			_VariableOldValue 	 = OLDVAL(FIELD(_N,lcAlias),lcAlias)
			_VariableOldValueType= TYPE('_VariableOldValue')
			Do Case
				Case _VariableOldValueType = [L]
					&_OldValue	 = IIF(_VariableOldValue,'.T.','.F.')
				OtherWise
					&_OldValue	 = ALLTRIM(PADL(_VariableOldValue,256))
			ENDCASE
			*:si el valor del campo cambio, entonces se registra el cambio, de lo contrario se omite
			IF _VariableNewValue <> _VariableOldValue THEN 
				lcString = lcString + &_FieldName + ' ' + &_OldValue + ' ' + &_NewValue + ' '
			ENDIF 
		ENDFOR 
		SET STEP ON 
		IF !EMPTY(lcString) THEN 
			lcFieldToUpdate = lcAlias + '.' + lcFieldToUpdate
			replace  &lcFieldToUpdate WITH &lcFieldToUpdate + CHR(13) IN &lcAlias  &&err message here
		ENDIF 
	CASE lcAction = 'D'	
ENDCASE 
RETURN .T. 
.......
DO WHILE .T.
      ME.Work()
ENDDO
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform