Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Insert - Update Trigger
Message
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Insert - Update Trigger
Divers
Thread ID:
00930389
Message ID:
00930389
Vues:
45
From Insert and Update triggers the following code is run from a stored procedure in the DBC. Part of our process was collecting information from other Databases and either updating or inserting records based on certain criteria. During this process we were getting error 2034 "Date/Datetime evaluted to an invalid value". This would occur when the information we were receiving had funky date values (example would be 01/01/0204 rather than 01/01/2004). Since i have no control over checking validity of dates, we are simply updating new DBC with these values.
cNewChanges=''

For lnField = 1 To Fcount(LCTABLE)

	If Transform(Oldval(Field(lnField,LCTABLE))) != Transform(Evaluate(Field(lnField,LCTABLE)))
					
		cNewChanges = cNewChanges +'<fld>'+FIELD(lnField)+'</fld>'+CHR(13)+;
			'<typ>'+TYPE('EVALUATE(FIELD(lnField))')+'</typ>'+CHR(13)+;
			'<old>'+Transform(Oldval(Field(lnField,LCTABLE)))+'</old>'+CHR(13)+;
			'<new>'+Transform(Evaluate(Field(lnField,LCTABLE)))+'</new>'+Chr(13)
	ENDIF

Endfor

If !Empty(cNewChanges)
	Select Log
	Append Blank
	Replace ACTION With LCACTION, ;
		RECORD_PK With lcRecord, ;
		CTABLE With LCTABLE, ;
		DATA_BASE With lcSelectedDBC, ;
		userid With lcUserID, ;
		D8 With Datetime(), ;
		ident With Sys(0),;
		changes With cNewChanges
Endif
In trying to debug why we were getting these errors, I found that in the stored procedure the
"Evaluate(Field(lnField,LCTABLE))" code was the problem. It seems that with a funky date being written to the record, the logging stored procedure would throw an error. However, the field would be updated to the funky date with no problem. Also if I go directly to the table and enter this date all is well. If I do a replace or an Update Sql all is fine from the command window, however when replaced or updated within the program the error would happen. Totally confused as why in the stored procedure I am not able to determine what the field value for the funky date can not be determined.

Any hints or suggestions would really be appreciated. Presently I am trapping for error and logging those separately, but frustrated in not being able to determine why the error is happening.

(hope this all makes sense)
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform