NetTalk Central

Author Topic: NetWebServiceMethod - AddFile question (v 10.15)  (Read 4689 times)

Thys

  • Sr. Member
  • ****
  • Posts: 311
    • View Profile
    • Incasu
    • Email
NetWebServiceMethod - AddFile question (v 10.15)
« 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

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: NetWebServiceMethod - AddFile question (v 10.15)
« Reply #1 on: March 05, 2018, 07:39:03 AM »
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

Thys

  • Sr. Member
  • ****
  • Posts: 311
    • View Profile
    • Incasu
    • Email
Re: NetWebServiceMethod - AddFile question (v 10.15)
« Reply #2 on: May 20, 2018, 10:53:36 PM »
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

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: NetWebServiceMethod - AddFile question (v 10.15)
« Reply #3 on: May 24, 2018, 12:54:26 AM »
see my reply to the delete action question -
I've tweaked this for the 10.22 build to return the correct error codes.