php - I can't fetch temp table data from store procudere -
i created on store procedure in sql server below structure
alter procedure [dbo].[list_final_player_report] -- add together parameters stored procedure here @teamid int begin create table #temptable ( playername varchar(50), rank_in_speedladdar int, rank_in_120s int, rank_in_cone int, rank_in_beep int, rank_in_cooper int, rank_in_pushups int, rank_in_situp int, rank_in_pullup int, rank_in_40s int, rank_in_pushopbattle int, rank_in_vertical_jump int, rank_in_shuttle int ) declare @playerid int declare @firstname nvarchar(10) -- define cursor declare cursor1 cursor select players.playerid playerid , players.firstname players teamid=@teamid -- should open cursor open cursor1 -- need fetch rows @empid variable fetch cursor1 @playerid,@firstname --looping while(@@fetch_status=0) begin insert #temptable values(@firstname, (select (sum(total))/count(playerid) challengestats challengestats.challengeid =1 , challengestats.playerid=@playerid ), (select (sum(total))/count(playerid) challengestats challengestats.challengeid =2 , challengestats.playerid=@playerid ), (select (sum(total))/count(playerid) challengestats challengestats.challengeid =3 , challengestats.playerid=@playerid ) , (select (sum(total))/count(playerid) challengestats challengestats.challengeid =4 , challengestats.playerid=@playerid ) , (select (sum(total))/count(playerid) challengestats challengestats.challengeid =5 , challengestats.playerid=@playerid ) , (select (sum(total))/count(playerid) challengestats challengestats.challengeid =6 , challengestats.playerid=@playerid ) , (select (sum(total))/count(playerid) challengestats challengestats.challengeid =7 , challengestats.playerid=@playerid ) , (select (sum(total))/count(playerid) challengestats challengestats.challengeid =8 , challengestats.playerid=@playerid ) , (select (sum(total))/count(playerid) challengestats challengestats.challengeid =9 , challengestats.playerid=@playerid ) , (select (sum(total))/count(playerid) challengestats challengestats.challengeid =10 , challengestats.playerid=@playerid ) , (select (sum(total))/count(playerid) challengestats challengestats.challengeid =11 , challengestats.playerid=@playerid ) , (select (sum(total))/count(playerid) challengestats challengestats.challengeid =12 , challengestats.playerid=@playerid ) ) fetch cursor1 @playerid,@firstname end close cursor1 deallocate cursor1 select * #temptable end
this sp execute in sqlserver
but problem how temp table info php resultset
instead of using temp table, why not utilize table variable. should not have alter much code in order implemented.
declare @temptable table ( playername varchar(50), rank_in_speedladdar int, rank_in_120s int, rank_in_cone int, rank_in_beep int, rank_in_cooper int, rank_in_pushups int, rank_in_situp int, rank_in_pullup int, rank_in_40s int, rank_in_pushopbattle int, rank_in_vertical_jump int, rank_in_shuttle int )
temp tables during scope of used, causing issue. seek above, , should different result.
php sql-server
No comments:
Post a Comment