Re: Retrieving SERIAL identifiers in a concurrent environment



So, in order to exploit it as a SQL query result, I should address a
statement such as this (please gimme your advice...):

SELECT SQLCA.SQLERRD[2];

Is that right?
Furthermore: is that concurrency-proof (is it isolated from concurrent
connections)?

Thanks, Keith

Simmons, Keith wrote:
Salvo

Havn't got manuals available, but  think the SQLCA record is your friend.
This contains the return code of any sql statement and item SQLERRD[2]
contains the serial of the last inserted record.

Keith

-----Original Message-----
From:	Salvo Giubili [SMTP:colchicumNoSpmAbse@xxxxxxxxxxxx]
Sent:	Sunday, January 01, 2006 3:54 PM
To:	informix-list@xxxxxxxx
Subject:	Retrieving SERIAL identifiers in a concurrent environment

Hello all

Working on IDS 9.30, I need to retrieve the identifier (say:
SERIAL-typed ID as primary key) of the latest row immediately after
having inserted it, so that I'm able to refer it in related tables.

Till now I've used the simple-though-awkward (brute force!) "SELECT
FIRST 1 ID FROM myTable ORDER BY ID DESC" SQL statement just after the
INSERT statement. Now I've to cope with concurrent users, and such an
approach clearly isn't feasable.

I'd prefer not to lock the entire table but, although I skimmed the web
for documentation, I actually feel uncertain yet...

What's the most reliable method for retrieving last-generated
identifiers in an Informix concurrent environment?
.



Relevant Pages

  • Re: SQL
    ... Dan, thanks thats useful. ... the data model is not complicated at all. ... you should use SQL Server if you ... > and/or you expect to have more the 5 concurrent users. ...
    (microsoft.public.access.modulesdaovba)
  • Re: Tool to perform stress test on PDA replication
    ... I'm not familiar enough with thie setup to know if this is possible - but can ... you start several concurrent PC Emulators? ... can the SQL CE instances be ...
    (microsoft.public.sqlserver.replication)
  • Re: MSDE2000 Rel A & Internet hosted App
    ... with a business objects reporting software which allows users to view ... reports against a sql database hosted on a different machine. ... app references a sql odbc to attache to the sql server and database. ... on the website outline that this is ideal for upto 25 concurrent sessions. ...
    (microsoft.public.sqlserver.msde)
  • Re: Concurrent User limitation?
    ... There is no real limit to the concurrent user connections, ... a limit to the number of concurrent workloads. ... spends most time entering data on the form, and only a fraction of the ... The limit on concurrent workloads is set to 8 workloads, but since SQL ...
    (microsoft.public.sqlserver.msde)
  • Re: MV Keys
    ... "could this removeAt operation possibly be useful ... in a concurrent environment?" ... a second prize for 2nd place, and remove the third prize (desired effect: 2 silver medals, no bronze medal). ...
    (comp.databases.theory)