December 31, 2013 at 2:01 am
Hi All,
I have been trying to get a Store Procedure to return a value for success or failure back to a PHP web application that's calling it.
But i'm having absolutely no joy as PHP is not getting anything back, output param works fine in SQL though.
So I have decided to use a Select instead. Are there any pitafalls in using a Select for returning something over an output parameter?
Many Thanks
B
December 31, 2013 at 2:29 am
this would not hurt only if this store procedure is executed independently. if you are using this store procedure in side a store procedure then it could hurt u.
its a very regular thing to have an output parameter calling in a PHP. i would suggest u should do some Google on this related issue. i might not be the 1st one to have this issue. π
December 31, 2013 at 3:12 am
twin.devil (12/31/2013)
this would not hurt only if this store procedure is executed independently. if you are using this store procedure in side a store procedure then it could hurt u.its a very regular thing to have an output parameter calling in a PHP. i would suggest u should do some Google on this related issue. i might not be the 1st one to have this issue. π
I did get the output parameter working using the mssql library but it does not work on Linux server where you have to use dblib for PDO, PHP -> MSQL connections. That is why I had to resort to using the select.
December 31, 2013 at 4:34 am
you just need to make sure that this procedure is not in use in any other procedure beside that no harm using this approach.
December 31, 2013 at 5:05 am
The return value of a stored procedure is traditionally used for this:
RETURN 0 if the procedure ran successfully
RETURN -n if the procedure failed.
ALTER PROCEDURE TestOutput @Outcome CHAR (4)
AS IF UPPER(@Outcome) = 'FAIL' RETURN -1
RETURN 0
GO
DECLARE @Returnvalue INT
EXEC @Returnvalue = TestOutput 'PASS'
PRINT @Returnvalue
--prints 0
EXEC @Returnvalue = TestOutput 'FAIL'
PRINT @Returnvalue
--prints -1
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply