Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 7 of 7 total
Thread when TDatabase AutoTransactions is true, after commit, how to update dataset's autoincrease ID
Sat, Sep 3 2016 9:20 AMPermanent Link

kentersoft

Hi,

 I just test mormot as web server, after commit, server return a integer json array indicate the result,
when update or delete, 200 means ok, when insert, the integer value mean the Added ID, since every
table have an autoincrease ID column as primary key, after commit, how to get the id value to
update the dataset's id column? the return integer array json just like this [200,200,1,2,3,4]...
 TDatabase seems no event relate to this.

thanks!
Sat, Sep 3 2016 10:48 AMPermanent Link

erickengelke

> I just test mormot as web server, after commit, server return a integer json array indicate the result,
when update or delete, 200 means ok, when insert, the integer value mean the Added ID, since every
table have an autoincrease ID column as primary key, after commit, how to get the id value to
update the dataset's id column? the return integer array json just like this [200,200,1,2,3,4]...
 TDatabase seems no event relate to this.

I don't have a definitive answer but:

I know Mormot returns the new TID, which is very helpful.
.
Typical SQL does not return anything after an SQL operation.

What I always do is refresh my table and detail after an add operation.  This seems like a smart idea because other people may have added data since our last table refresh.

Erick
Sat, Sep 3 2016 7:17 PMPermanent Link

kentersoft

<
What I always do is refresh my table and detail after an add operation.  This seems like a smart idea because other people may have added data since our last table refresh.

Erick
>

In grid edit, sometime the transaction is auto occur because cursor move, you can't know where to refresh, anyway thank your hit.
Sat, Sep 3 2016 8:47 PMPermanent Link

Trinione

kentersoft wrote:
<<  I just test mormot as web server, after commit, server return a integer json array indicate the result,
when update or delete, 200 means ok, when insert, the integer value mean the Added ID, since every
table have an autoincrease ID column as primary key, after commit, how to get the id value to
update the dataset's id column? the return integer array json just like this [200,200,1,2,3,4]...
 TDatabase seems no event relate to this. >>


Hi:
Check the following thread:

Subject: last insert id ? Go to: http://bit.ly/2bUJg7x
Sat, Sep 3 2016 8:49 PMPermanent Link

Trinione

<<Check the following thread:
Subject: last insert id ? Go to: http://bit.ly/2bUJg7x >>


In one of the comments Tim stated:

>>> BTW, I forgot to mention yesterday that I'll be adding "echo" support to the transaction commits in 2.03 or 2.04 when I enhance the database layer.  That will allow you to retrieve autoinc/identity/generated/computed column values after inserts/updates without additional requests to the web sever.
Sat, Sep 3 2016 9:34 PMPermanent Link

kentersoft

Trinione wrote:

<<Check the following thread:
Subject: last insert id ? Go to: http://bit.ly/2bUJg7x >>


In one of the comments Tim stated:

>>> BTW, I forgot to mention yesterday that I'll be adding "echo" support to the transaction commits in 2.03 or 2.04 when I enhance the database layer.  That will allow you to retrieve autoinc/identity/generated/computed column values after inserts/updates without additional requests to the web sever.


It looks somewhat similar, but it's a batch update, in response array, already have the new ids, no need to go server again, i look the TDatabase's Rollback function, since the response array is same length as the datasetoperations, so we need loop through the datasetoperations like Rollback function, update the id, it's enough, also the response perhaps is ["OK"] for all success and no insert operation, for this response just do nothing.
Tue, Sep 6 2016 8:16 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

<< I just test mormot as web server, after commit, server return a integer json array indicate the result,
when update or delete, 200 means ok, when insert, the integer value mean the Added ID, since every
table have an autoincrease ID column as primary key, after commit, how to get the id value to
update the dataset's id column? the return integer array json just like this [200,200,1,2,3,4]...
 TDatabase seems no event relate to this. >>

This will be coming in an upcoming minor release.  It just didn't make it into 2.05, due to the delays in implementing the design-time changes for intra-component references.

Tim Young
Elevate Software
www.elevatesoft.com
Image