Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Insert - Update Trigger
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00930389
Message ID:
00930509
Views:
10
Hi Ron,

When date format is set to SHORT or LONG a date before {^1601-01-01} is considered invalid and will generate an error.
ldDate = {01/01/0204}
? TRANSFORM(ldDate)    && Ok
SET DATE LONG
? TRANSFORM(ldDate)    && Error
* Temporary change date format and restore after date conversion
lcSaveDateFormat = SET("Date")
SET DATE AMERICAN
? TRANSFORM(ldDate)
SET DATE (lcSaveDateFormat)
>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
>
>
>
>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)
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform