473,698 Members | 2,076 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

mysql_insert_id () & stored procedure

if my query is a regular INSERT, then mysql_insert_id () works as expected.

But if I use a Stored Procedure to do my insert, then mysql_insert_id () returns 0

How can I get a returned autoincrement (my primary key) when using a stored
procedure? Thanks.
Aug 19 '08 #1
1 2913
On Aug 19, 1:17 pm, Fred <F...@notspam.n otwrote:
if my query is a regular INSERT, then mysql_insert_id () works as expected.

But if I use a Stored Procedure to do my insert, then mysql_insert_id () returns 0

How can I get a returned autoincrement (my primary key) when using a stored
procedure? Thanks.
Try using the stored procedure itself to return the
inserted id or change the stored procedure by a
function -- I don't know if it is allowen in MySQL.

Also, the return value of the stored procedure can
be used to verify the integrity of the insert statement.

Regards,
DMW

Aug 19 '08 #2

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

Similar topics

3
2571
by: Dan Sikorsky | last post by:
How can I get the recordset attributes for a table field in SQL Server 2000 to report the field updatable attribute correctly ... mine keeps saying the fields are not updatable? That is, ( oRecordSet ( oItem ).Attributes & 0x4) is always 0 for every field on SQL Server 2000 Example code: var sSQL = 'SELECT TOP 1 * FROM WHERE ' + sUniqueField + '=' + sUniqueValue + ';';
2
1744
by: Anthony Judd | last post by:
Hi all, Just a quick question. I am using Sql Server 2000 and calling stored procedures from asp. At this stage i am forgoing using the ADO command object and am simply create dynamic like sql statement for store procedure execution. My question is, I find the code below quite messy, particularly when it comes to checking for option parameters using if statements. Is their a better way to write this, keeping in mind i have to check in...
2
10163
by: Jegg | last post by:
I wrote a web app using an ASP front end (not .NET) connecting to a SQL Server 2000 (no SP) back end. Both the web server and the database server are Windows 2003 boxes. The app was running fine two weeks ago before I went on vacation. While I was gone my net admin applied Windows 2003 SP1 to the web server. Upon my return I was informed that the app is no longer working, getting the following error: Connection is busy with results...
3
2478
by: Niyazi | last post by:
Hi, Me again. I want to create a SQL Server StoreProcedure and I want to access it with ADO.NET. I am using VB.NET. Creating StoreProcedure it was easy but my question is this. I have table with 4 Column and 6 rows. In the Column 3 for all rows I have to insert data. The data considt of the decimal value of Croiss Exchange and 6 my variable as:
6
4684
by: opt_inf_env | last post by:
Hi, I would like to insert a data (row) into database (MySQL) and than to generate file whose name contains the ID of the inserted row (ID is declared as AUTO_INCREMENT). I wanted to extract ID by mysql_insert_id() function. However, the problem is that my web site can visit many users and many of them can initiate the describe procedure. It can happen that between the first user inserts something into database and executes...
0
2356
by: Springflower | last post by:
Hi, I am new to using DB2 Development Center. I had downloaded the trial version(8.2) of latest DB2 UDB and want to write a stored procedure in COBOL. When I chose the oprion the wrting a new stored procedure, it had given me the following two language options:
5
2155
by: James Wong | last post by:
Hi, I am writing a vb.net2005 program that needs to create a stored procedure with SqlServerProject Template. Now, I have two questions for this stored procedure. 1) How can I import and execute the .dll in this Stored Procedures? 2) How can I connect the Web Service and get the result in this Stored Procedures?
4
4359
by: scparker | last post by:
Hello, We have a stored procedure that does a basic insert of values. I am then able to retrieve the ID number created for this new record. We are currently using ASP.NET 2.0 and use N-Tier Architecture. The Stored Procedures are used through TableAdaptors, which in turn are used by Class Files. I wish to be able to return this new ID value using the Stored
2
1589
by: Neil | last post by:
I'm using Access 2000 with a SQL 7 back end. I recently implemented some code in a form's AfterUpdate event which calls a stored procedure which copies the contents of the current record to a history table. The code works fine when the user edits and saves the record. However, if the user performs a Find and Replace, the code hangs. At first I thought the code was hanging because of multiple records being replaced. But when I debugged...
0
8674
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8603
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8893
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8861
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7721
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4615
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2327
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.