NetTalk Central

NetTalk Web Server => Web Server - Ask For Help => Topic started by: Thys on March 18, 2019, 10:52:54 AM

Title: NetWebServiceMethod - how to deal with server-side autoincrement
Post by: Thys on March 18, 2019, 10:52:54 AM
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
Title: Re: NetWebServiceMethod - how to deal with server-side autoincrement
Post by: Bruce on March 21, 2019, 06:48:00 AM
added for 11.08