NetTalk Central

NetTalk Web Server => Web Server - Ask For Help => Topic started by: Thys on February 28, 2019, 04:08:05 AM

Title: NetWebServiceMethod - CheckForDuplicates find duplicate without any records
Post by: Thys on February 28, 2019, 04:08:05 AM
Hi,

I have several db-methods that each gives an error when inserting a new record:

Cannot save a duplicate record. Record is duplicating another on the following fields:OBJ__GUID = 91ZJQHTR4IJ8AZ7L

The error is generated in the p_web.CheckForDuplicates method, but there are no existing records in those tables. On all of the tables, the database (PostgreSQL) generates the primary key column value, so Clarion does not touch the column (using READONLY on the external column name in the DCT). I have NT 10.35 on Clarion 11.

Any ideas?
Thys
Title: Re: NetWebServiceMethod - CheckForDuplicates find duplicate without any records
Post by: Thys on February 28, 2019, 05:35:59 AM
Hi,

I've looked at the code surrounding the .CheckForDuplicates call in the InsertRecord: routine. Before this call, it also calls PrimeFields - where there is this funny code:


PrimeFields:Object  routine
  data
  code
  case lower(TableAction)
  of 'insert'
  orof 'add'
    If OBJ:guid = '' then OBJ:guid = packet.MakeGuid() .
  of 'update'
  orof 'change'
  End


It actually tests whether the guid column (the primary key column) is blank - if not it auto populates it. BUT in the DCT I've marked this column as READONLY. So it should not be primed here.

Also, if this column was not called "guid", would this behaviour be the same? I've called it this out of habit. Should it be something else?

Thanks
Thys

Title: Re: NetWebServiceMethod - CheckForDuplicates find duplicate without any records
Post by: Bruce on February 28, 2019, 06:45:13 AM
I'd be interested in the dict so I can allow for this setup, but yeah it's matching on the name, so if you changed the name it would fix it for you.

cheers
Bruce
Title: Re: NetWebServiceMethod - CheckForDuplicates find duplicate without any records
Post by: Thys on February 28, 2019, 07:01:25 AM
Thanks Bruce. I've emailed it to you.
Title: Re: NetWebServiceMethod - CheckForDuplicates find duplicate without any records
Post by: Thys on February 28, 2019, 09:03:08 PM
Bruce,

Even after adding an EXIT statement at the start of the PrimeFields: routine, the CheckForDuplicates routine still reports that it's trying to add a duplicate record - but now with an empty guid value:

"Cannot save a duplicate record. Record is duplicating another on the following fields:OBJ__GUID ="

Thys
Title: Re: NetWebServiceMethod - CheckForDuplicates find duplicate without any records
Post by: Bruce on March 01, 2019, 12:39:11 AM
>> BUT in the DCT I've marked this column as READONLY. So it should not be primed here.

fixed in 11.08

>> the CheckForDuplicates [method] still reports that it's trying to add a duplicate record

fixed in 11.08

cheers
Bruce
Title: Re: NetWebServiceMethod - CheckForDuplicates find duplicate without any records
Post by: Thys on April 08, 2019, 04:22:30 AM
Hi Bruce.

How did you fix the problem? I would like to do the same in the code - and get the "formal" fix when 11.08 is available.

Thanks
Thys
Title: Re: NetWebServiceMethod - CheckForDuplicates find duplicate without any records
Post by: Bruce on April 10, 2019, 10:05:51 PM
That might be tricky now Thys - not sure what all has changed in the template file until I do a merge.
I'll try and expedite the 11.08 release next week.

cheers
Bruce
Title: Re: NetWebServiceMethod - CheckForDuplicates find duplicate without any records
Post by: Thys on April 11, 2019, 04:17:23 AM
Thanks. Until then I've changed the CLW file not to run the code in CheckForDuplicates. It works out that if there was a duplicate then SQL returns the correct error description.