I created a stored proc in SQL Server like so
CREATE PROCEDURE sp_myproc @a VARCHAR(250), @b VARCHAR(250) AS BEGIN TRAN ..bunch of code.. DECLARE @id NUMERIC, @newid NUMERIC SELECT @id = id, @newid = (id + 1) FROM sometable WHERE (some condition) ..more bunch of code.. -- Now, insert a new record in request INSERT INTO anothertable (id, othercols) VALUES (@id, othervals) -- Update the request id UPDATE yetanothertable SET id = @newid WHERE (someothercondition) COMMIT TRAN RETURN @id
Which I call via DBD::OBDC like so
my $sth = $dbh->prepare("EXEC sp_myproc ?, ?"); my $id = $sth->execute('foo', 'bar');
Obviously my code above is wrong because the $id captured by the Perl code is not the same as the @id created in the stored proc. My $id is always 1, which is, I am guessing, indicating success at running the stored proc. I want to get back that @id that I created in the stored proc.
In general, how do I get one or more values back from a complicated (or not so) stored procedure back in my Perl code so I can work with it?
Many thanks in advance.
In reply to Capturing a value returned from a stored procedure by punkish
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |