473,406 Members | 2,619 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

getting the key of an inserted record

hg
Hi,

I want to use a table with an auto-incremented key and some non-unique
field (date ...)

I want to insert a record and get its key value right away - I am in a
multi-threaded environment, so after my commit, someone else might
insert a record ... before I can fetch my key value.

Is there a way ?

BTW: I'm doing this from Python.

Thanks.

hg
Sep 15 '06 #1
2 2732
hg wrote:
I want to use a table with an auto-incremented key and some non-unique
field (date ...)

I want to insert a record and get its key value right away - I am in a
multi-threaded environment, so after my commit, someone else might
insert a record ... before I can fetch my key value.

Is there a way ?

BTW: I'm doing this from Python.
Use LAST_INSERT_ID() SQL function or the mysql_insert_id() C API
function. At least php has similar function so I assume Python has one
too, but I don't know what name or how to use it. But at least the SQL
function can be used with any language.
Sep 15 '06 #2
hg
Aggro wrote:
hg wrote:
>I want to use a table with an auto-incremented key and some non-unique
field (date ...)

I want to insert a record and get its key value right away - I am in a
multi-threaded environment, so after my commit, someone else might
insert a record ... before I can fetch my key value.

Is there a way ?

BTW: I'm doing this from Python.

Use LAST_INSERT_ID() SQL function or the mysql_insert_id() C API
function. At least php has similar function so I assume Python has one
too, but I don't know what name or how to use it. But at least the SQL
function can be used with any language.
Thanks,

will that work before the commit ?

hg
Sep 15 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: PT | last post by:
I got a problem. And thats..... First of all, I got these three tables. ------------------- ------------------ ---------------------- tblPerson tblPersonSoftware ...
6
by: Billy Cormic | last post by:
Hello, I would like do an insert into a table. The table has an auto incrimenting unique int id. After I do the insert how do i get the unique int id of the record that I just inserted? Is...
9
by: Robert Schneider | last post by:
Hi to all, I don't understand that: I try to delete a record via JDBC. But I always get the error SQL7008 with the error code 3. It seems that this has something to do with journaling, since the...
3
by: Mark | last post by:
I'm using ASP.Net to accress a database, what I need to do is get the fields out of the very last record in the db. How do I do this? Actually I'm after the primary key, titled 'AdID' it'll tell...
3
by: Jason L James | last post by:
Hi all, I recently wrote a vb.net app using oledb to an access database. When I inserted new rows in my datatable the identity column was automatically created. This app used an un-typed...
1
by: Craig | last post by:
In ASP.NET 2.0 and the formview control how do you get the value of the identity field of a newly inserted record? In ASP.NET 1.1 after the new record was saved you just said intNewIdentityID =...
5
by: Jan | last post by:
Hello, Just after the new record is inserted in the database using a Detailsview control, i would like to display a short message "the record is inserted". In the aspx file, i defined a...
4
by: nch1978 | last post by:
I am new to programming and am sorry if this post is in the wrong area. I have a listbox bound to a table and a datagrid bound to another one with a connection through xml. I can change the data...
2
by: TimSki | last post by:
Hi, In my asp page I am inserting a record in to the sql server 2005 db as follows... OpenDataConnection() oConn.BeginTrans set cm = CreateObject("ADODB.Command") set cm.ActiveConnection =...
2
by: HotFrost | last post by:
Hello everyone, i am trying to work with linked servers... The local server is the one used by UPS worldwide software (it is Microsoft SQL Server Desktop Engine, v 8.00.2050). The linked server...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.