I have spent months trying to eliminate crashes in several procedures, which operate in a similar fashion, in a shared database. The crashes come in waves: once the procedure crashes, it will crash several times in a row. Then it may work 10, 20, or more times without a problem. The code first defines and assigns values to several variables, then adds a record and assigns the variable values to various fields in the newly added record.
/* Code first defines and assigns values to the variables. Never had a crash here.
Then does this: */
addrecord
DT="B" //DT is a field name. Each subsequent begins with a field name
Matterno=fgmatter
Invoice=fginv
Date=fginvdate
HCDebit=val(fghc)
Field HCDebit runfieldcalculations
SCDebit=val(fgsc)
Field SCDebit runfieldcalculations
Initials="SD"
Billno=lvbillnum
DateCreated=today()
ShortName=fgShortName
Based on logging statements, it appears the program fails when the first assignment is reached, in this case, DT=“B”. Upon restarting, typically I find one empty row has been added.
My most recent effort at a fix is to insert an Alertsheet statement immediately after the Addrecord. This introduces a pause. After ten tests, the procedure has run without a failure. But I am not ready to declare success yet. In any event, introducing the requirement would be a partial success at best; there is no good reason for the user to have to intervene.
My procedure also goes on to add more records, but I have never had a failure anywhere but around the first addrecord; assignment statements.
I will also add that I previously used console statements to show the progress of the procedure. At first I believed that the code failed exactly where the console statements suggested: after the last console state that appeared in the console, and before the next one. But at some point I began to doubt that; the code may have gone on for many rows and then failed, and also failed to post/send the message from several rows earlier to the console. So I am not sure this will actually pinpoint the problem code.
Any solutions or ideas would be welcome.