Subject Re: sql RETURNING
From John Linares <> <John Linares <>>
Date Fri, 03 May 2019 23:34:23 +0100
Newsgroups sqlexpress

Boris
Retrieving last sequence value does not warratee accuracy for serial columns
putting this in perspective
In a multiuser environment and multiple operations in parallel on the same master slave table
OPER 1                        OPER 2
INSERTS SERIAL 1              INSERT SERIAL 2
RETRIEVES LAST SERIAL GETS 2  RETRIEVES LAST SERIAL GETS 2   **** same id ****
THAT HAPPENED IN MY TRANSACTIONS FROM TIME TO TIME
I HAD TO serialize an id to retrieve it later on AND get the current id to my slave foreign column  
There should be a way to obtain the returning value of a sql command
Best Regards
John
Boris Borzic <bb> Wrote:

> John Linares <> wrote in
> news:wgti6i13k5mvzvz.160720140900@WIN-SRT7GF05O4J:
>
> > In fact, I have a select statement retrieving last sequence or serial
> > number of  the table. That changes a little the logic, it'd be  faster
> > and simpler to read in return last serial number in the same INSERT
> > statement, besides I would like to have in return a table or a full
> > record, maybe you should consider extending your lib  with that
> > feature as improvement or alternative in your  future version.
>
> In agree that this would be simpler, unfortunately it is not supported by
> ODBC. In order to get the last inserted sequence #, you will need to
> execute the following after your INSERT:
>
> SELECT LASTVAL()
>
> You can simplify this yourself by creating one function that does it all.
>
> --
> Best regards,
> Boris Borzic
>
> http://xb2.net
> http://sqlexpress.net
> industrial strength Xbase++ development tools


Recent messages in this thread
 
-# Re: sql RETURNING (Current message) John Linares <> 03-May-2019 06:34 pm
.-# Re: sql RETURNING Boris Borzic <bb> 04-May-2019 08:09 am
.|-# Re: sql RETURNING John Linares <> 15-Jul-2019 03:42 pm
.|.-# Re: sql RETURNING Boris Borzic <bb> 15-Jul-2019 07:36 pm
.|..-# Re: sql RETURNING John Linares <> 17-Jul-2019 03:12 pm
.|...-# Re: sql RETURNING Edgar Borger 24-Jul-2019 12:02 pm
.|....\# Re: sql RETURNING AUGE_OHR <AUGE_OH... 24-Jul-2019 12:08 pm
.\# Re: sql RETURNING AUGE_OHR <AUGE_OH... 15-Jul-2019 05:49 pm