I was just wondering if there is any advantage of using an out parameter over just using a select statement after inserting a record and returning an autonumber PK field inside a Stored Procedure.
So, would there be any difference between doing this:-
And then retrieving the value in .NET using a parameter object or doing this:-Code:CREATE PROCEDURE AddSomething ( name VARCHAR(100), OUT id INT ) BEGIN INSERT INTO tbl (Name) VALUES ( name ) ; SELECT LAST_INSERT_ID() INTO id; END
And just using command.ExecuteScalar(); to retrieve the value.Code:CREATE PROCEDURE AddSomething ( name VARCHAR(100) ) BEGIN INSERT INTO tbl (Name) VALUES ( name ) ; SELECT LAST_INSERT_ID(); END
Does one have an advantage over the other?



LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks