Subject Re: sql RETURNING
From 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 11:34 pm
.-# Re: sql RETURNING (Current message) Boris Borzic <bb> 04-May-2019 01:09 pm
.|-# Re: sql RETURNING John Linares <> Mon, 08:42 pm
.|.-# Re: sql RETURNING Boris Borzic <bb> Tue, 12:36 am
.|..\# Re: sql RETURNING John Linares <> Wed, 08:12 pm
.\# Re: sql RETURNING AUGE_OHR <AUGE_OH... Mon, 10:49 pm