Subject Re: sql RETURNING
From Boris Borzic <bb> <Boris Borzic <bb>>
Date Sat, 4 May 2019 14:09:20 +0200
Newsgroups sqlexpress

John Linares <> wrote in news:7jk74qlbl3o3lmw.040520190034@daz17:

> 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

With SQL Server you can use "SELECT SCOPE_IDENTITY()" which returns the
value in the current scope (current user). It is multi-user safe. Maybe
PgSQL has a similar function (this is a PgSQL issue - nothing to do with
SQLExpress:

https://stackoverflow.com/questions/9477502/get-the-last-inserted-row-id-
with-sql-statement

--
Best regards,
Boris Borzic

http://xb2.net
http://sqlexpress.net
industrial strength Xbase++ development tools

Recent messages in this thread
 
-# Re: sql RETURNING John Linares <> 03-May-2019 06:34 pm
.-# Re: sql RETURNING (Current message) 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