Re: Getting result of odbc's INSERT INTO command



"Joe" <joerider@xxxxxxxxx> wrote:
> But before SELECT MAX(id) is executed connection 2 could also insert a
> record with any other program (or manually by using
> SQL-Enterprise-Manager)

This isnt a problem then, @@IDENTITY is stored 'per connection', therefore

Con1: INSERT INTO foo(foo1, foo2) VALUES('foot', 'mouth');
where foo [
LONG indexer auto_increment, not null, primary_key
foo1 <var>
foo2 <var>
]

If called for each connection, the driver stores the last auto_increment
field from the single connection - so use @@identity straight after you have
called it (ie: before any more queries) and you should get what you want.

If you do:
INSERT #1 on Con1
INSERT #2 on Con2
SELECT @@identity on Con1
SELECT @@identity on Con2

The first identity will be correct for con1, the second would be that
inserted by the second insert on con2.

- Mark R




.



Relevant Pages

  • Re: DB-Verbindungen: Korrekte Herangehensweise
    ... als Spezialfall an der in meiner allgemeinen Antwort nicht gesondert betrachtet ... Open DB ... Select key, value from FOO where ... jede offene Connection ist eine Stelle an der mit einer Fehlersituation ...
    (de.comp.lang.java)
  • postgresql installation
    ... there's no way I seem able to make a localhost tcp_ip connection. ... I went into the template1 database and set my password for my username so that I could make connections from localhost. ... I set the password to match "foo" and not the md5_hex version of "foo". ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx with a subject of "unsubscribe". ...
    (Debian-User)
  • Re: deep question on threadlocal with connection
    ... if using threadlocal to *copy* a connection (connect to ... if con3 uses preparestatement to update a record which con1 just ... I'm not very familiar with the internal workings of MySQL but I am familiar ...
    (comp.lang.java.programmer)
  • Bad form to access a *private variable* like _foo?
    ... Bad form to access a *private variable* like _foo? ... The reason I'm asking is that TurboGears/SQLObject mobel objects have ... an attribute called "_connection" that must be used to manually commit ...
    (comp.lang.python)
  • tunneling problem
    ... their ftp program (which is internal GoLive! ... through ssh for a secure connection. ... Password requested by 127.0.0.1 for user "shippy". ... put foo: PORT failed. ...
    (comp.security.ssh)