Signup · Login
Stardeveloper.com  
Home · Tutorials · Forums · Web Hosting Plans · Faisal Khan's Blog · Contact
Forums : ASP : ADO/ODBC : Return Value in Store Procedure Signup · Login
Author Thread
Return Value in Store Procedure
Posted in tutorial: Running Stored Queries in Access Database
·  Tomarsh
User
Joined: 31 Jan 2004
Total Posts: 1
Return Value in Store Procedure
Posted: 31 Jan 2004
Your article is very helpful.

What I wanted to know is if I can get a return value from the procedure. Basically what I need to do is enter data in one table, get the autonumber value it returns and enter it into another table, all in the same procedure. Is this possible ? All my searches turned out to be for ADP which is Access connected to SQL server. This is not what I need. I also came accross @ReturnValue, but that did not seem to work.

Please let me know if you have an idea.

Many thanks in advance.

Tomarsh
·  thierryt64
User
Joined: 6 Feb 2004
Total Posts: 4
Returning value from Access stored queries/procedures
Posted: 6 Feb 2004
Unlike SQL server, Access does not implement output variables, so an Insert procedure/query cannot return the value of a newly created autoinc key field, for example.
However, there is a way to retrieve this value, by executing a 2nd command to the ADO engine:
"SELECT @@IDENTITY"
will return the key value of the last record inserted, regardless of the table being used. (so make sure you call it right behind the Insert call)

That's it.

** Better burn bright than fade away ***
·  thierryt64
User
Joined: 6 Feb 2004
Total Posts: 4
Returning value from Access stored queries/procedures
Posted: 6 Feb 2004
Unlike SQL server, Access does not implement output variables, so an Insert procedure/query cannot return the value of a newly created autoinc key field, for example.
However, there is a way to retrieve this value, by executing a 2nd command to the ADO engine:
"SELECT @@IDENTITY"
will return the key value of the last record inserted, regardless of the table being used. (so make sure you call it right behind the Insert call)

That's it.

** Better burn bright than fade away ***

Users Who Have Visited This Thread In Last 24 Hours
6 Visitors

Login
UserName Or Email Address:       Password:       Auto-Login:    
· Create New User Account
· Send Forgotten Password by Email
 
© 1999 - 2009 Stardeveloper.com, All Rights Reserved.