NetTalk Central

Author Topic: NetWebServiceMethod - how to deal with server-side autoincrement  (Read 4758 times)

Thys

  • Sr. Member
  • ****
  • Posts: 311
    • View Profile
    • Incasu
    • Email
Hi,

When using MSSQL, new records are added with PK-values that the server allocates (typically using IDENTITY or NEWGUID defaults). In the Clarion dictionary, the READONLY attribute is added to the External Name of the column, which stops the Clarion driver to add the PK column in the INSERT statement. In the InsertRecord: routine, the statement p_web.AddServiceResult () is used to generate the response JSON. But the PK value has not been returned yet at that stage into the file buffer, so the response states the PK-value is zero (in the case of an integer-type).

One way could have been to set the AUTOINCUSESSCOPEIDENTITY option on the table to true, which uses SCOPE_IDENTITY() to return the last insert done on the same connection. But for some reason this does not work and returns an error. So my only solution is to make a call "SELECT @@INDENTITY" right after the insert, and bring the result back into the file buffer. But there is no embed point before the call to AddServiceResult - which would help me to get the inserted PK-value first before the JSON response is generated. Can this embed point be added please?

Thys

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11251
    • View Profile
Re: NetWebServiceMethod - how to deal with server-side autoincrement
« Reply #1 on: March 21, 2019, 06:48:00 AM »
added for 11.08