NetTalk Central
		NetTalk Web Server => Web Server - Ask For Help => Topic started by: Thys on March 04, 2018, 11:50:59 PM
		
			
			- 
				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
- 
				your assessment that errorcode() and error() will likely contain incorrect values is true.
 Unfortunately err is equally incorrect because AddFile returns a level - like level:benign, level:notify and so on so is also not the errorcode.
 
 To get the errorcode I guess you'd need to interrogate the ErrorClass, something I've not done myself.
 
 cheers
 Bruce
 
- 
				Hi Bruce.
 
 I added a similar question for the delete action just now, forgetting that you've already replied on the .AddFile question.
 
 In response to your reply, the ErrorClass would also have been reset after the subsequent calls after .AddFile and .DeleteFile - so I can't interrogate them given early enough given that there are no embed points to catch them. So maybe an extra embed point will help please?
 
 Thys
- 
				see my reply to the delete action question -
 I've tweaked this for the 10.22 build to return the correct error codes.