Re: Getting result of odbc's INSERT INTO command
- From: "Mark Randall" <markyr@xxxxxxxxx>
- Date: Sun, 24 Apr 2005 12:36:57 +0100
"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
.
- References:
- Getting result of odbc's INSERT INTO command
- From: Joe
- Re: Getting result of odbc's INSERT INTO command
- From: Severian [MVP]
- Re: Getting result of odbc's INSERT INTO command
- From: Joe
- Re: Getting result of odbc's INSERT INTO command
- From: Severian [MVP]
- Re: Getting result of odbc's INSERT INTO command
- From: Joe
- Re: Getting result of odbc's INSERT INTO command
- From: Mark Randall
- Re: Getting result of odbc's INSERT INTO command
- From: Joe
- Getting result of odbc's INSERT INTO command
- Prev by Date: Re: Getting result of odbc's INSERT INTO command
- Next by Date: Printer Connected? Help
- Previous by thread: Re: Getting result of odbc's INSERT INTO command
- Next by thread: Re: Getting result of odbc's INSERT INTO command
- Index(es):
Relevant Pages
|