Hello! I'm on the same boat right now!
I'm no expert, but i guess you need a SP with OUT parameter.
You should alter your sp, and add a out parameter.
getjop (@id INT, @design VARCHAR(200) OUT ) AS BEGIN --insert data here SET @design = inserted_id -- set your OUT parameter END
When you run your SP from laravel,
declare @design as varchar(200) ; exec getjop 2 , @design output ; select @design
This above code works in SQL management studio...
What i'm having a hard time is to retrieve the OUT parameter back to php!
Did you manage to work this out?
Please check this!! Got me working!!
But my SP working, needed the declare before and select afterwards...
If you need some example code, let me know!
I never posted the solution I figured out, so here it goes if anyone else needs it. This example shows you how to return the newly created id.
Example MS Stored Procedure
CREATE PROCEDURE ReturnIdExample ( @paramOne int ,@paramTwo nvarchar(255) ) AS SET NOCOUNT ON; --IMPORTANT! BEGIN INSERT INTO [Table] ( [ColumnNameA] ,[ColumnNameB] ) VALUES ( @paramOne ,@paramTwo ) END -- Grab the id that was just created DECLARE @ObjectID int; SET @ObjectID = SCOPE_IDENTITY(); -- Select the id to return it back to laravel [email protected] AS ObjectID;
Now in your controller $submit = DB::select("EXEC ReturnIdExample ?,?", array( $paramOne ,$paramTwo ) );
This is how I was able to solve my problem.
Sign in to participate in this thread!
We'd like to thank these amazing companies for supporting us