Hi,
Below is an extract from the InsertRecord:Event routine that inserts a record to the EVENT table. I notice that the AddServiceErrorResult calls use ERRORCODE and ERROR to display the nature of errors, but in Clarion the values returned are adjusted whenever subsequent Clarion statements are called before it evaluates the original error.
In particular, look at the statement
err = p_web.AddFile(Event)
Where it is actually being reported on (7 lines lower), it uses the ERRORCODE and ERROR functions to report the nature of the error, but these values have both been reset to zero and blank - possibly because of a subsequent call to p_web.SqlRelease.
The only assumption that I have of the nature of the error, is to use the Err variable - that (I hope) corresponds to what the ERRORCODE () function would return. Please confirm whether this reasoning is correct.
Clear(EVN:Record)
do QueueToFile:Event
TableAction = 'insert'
do PrimeFields:Event
Do ValidateRecord:Event
If err = 0
Get(Event,0) ! Prime duplicate checking for Insert
errString = p_web.CheckForDuplicates(Event)
if ErrString
p_web.AddServiceError(DupKeyErr,'dbEvent', p_web.RecordIdentifier(Event), clip(ErrString),'')
Else
If p_web.sqlsync then p_web.SqlWait(p_web.SqlName).
err = p_web.AddFile(Event)
If p_web.sqlsync then p_web.SqlRelease(p_web.SqlName).
if Err = 0
if Event_Action <> 'sync'
p_web.AddServiceResult(Event_Action,'Event',p_web.RecordIdentifier(Event),'success')
end
Else
p_web.AddServiceError(Err,'dbEvent',p_web.RecordIdentifier(Event), 'Error when attempting to Insert a record [' & errorcode() &'] ' & error(), '')
End
End
Else
p_web.AddServiceError(Err,'dbEvent',p_web.RecordIdentifier(Event), 'Error when attempting to Insert a record [' & errorcode() &'] ' & error(), '')
End
Thys