A problem occurred when calling the mssql stored procedure on the linked server. An error occurred while calling the mssql stored procedure on the linked server in php. Which of the following has encountered a similar problem?
// Omit other statements
$ QueryP = "exec OA_pfm_attend_group_toExempt @ begin = '$ DATE1', @ end = '$ date2 '";
$ Cursor = msexequery ($ msconnection, $ queryP );
// Omit other statements
// The combination of $ queryP is: exec OA_pfm_attend_group_toExempt @ begin = '2017-03-01 ', @ end = '2017-03-24'
There is no problem with the execution of the query analyzer in the stored procedure. after all the statements using the linked server are deleted, php call is no problem. Is it because the stored procedure called by php cannot use the linked server? I am trying to write an asp file. I have no problem. [after testing, the stored procedure is executed under asp without any questions.]
Php error information has no reference value:
Error #0:
SQL statement: exec OA_pfm_attend_group_toExempt @ begin = '2017-03-01 ', @ end = '2017-03-24'
Sqlserver event tracking and log information cannot find useful information.
Stored Procedure code:
Drop proc OA_pfm_attend_group_toExemptgoCreate proc OA_pfm_attend_group_toExempt @ begin datetime, @ end datetimeasbegin set nocount on set ANSI_WARNINGS on set ANSI_NULLS on -- declare @ begin datetime -- declare @ end datetime -- set @ begin = @ beginSTR -- set @ end = @ endSTR create table # query_Table_Temp (checkDay datetime not null, checkIn datetime not null, checkOut datetime not null, isHoliday bit not null default 0) declare @ checkDay datetime declare @ checkIn datetime declare @ checkOut datetime set @ checkDay = @ begin while (@ checkDay <= @ end) begin set @ checkIn = convert (varchar (10 ), @ checkDay) + '08:35:00 'set @ checkOut = convert (varchar (10), @ checkDay) + '18:30:00' insert into # query_Table_Temp (checkDay, checkIn, checkOut) values (@ checkDay, @ checkIn, @ checkOut) -- update # query_Table_Temp set isHoliday = 1 where checkDay in (select Holiday from OPENQUERY (OAMySQL, 'select * from a_rest_holiday ')) set @ checkDay = dateadd (day, 1, @ checkDay) end delete from # query_Table_Temp where checkDay in (select Holiday from OPENQUERY (OAMySQL, 'select * from a_rest_holiday ')) -- this sentence causes an error. if you delete all the statements that call the linked server, the create table # attend_Temp (checkDay datetime not null, userID int, Name varchar (30 ), user_ID varchar (30), dept_ID int, defCheckIn datetime, defCheckOut datetime, checkIn datetime null, checkOut datetime null, rest bit not null default 0, leave1 bit not null default 0, leave2 bit not null default 0, out1 bit not null default 0, out2 bit not null default 0, evection bit not null default 0) insert # attend_Temp (checkDay, userID, Name, User_ID, dept_ID, defCheckIn, defCheckOut) select. checkDay, B. userID, B. name, B. oa_UserID, B. defaultDeptID,. checkIn,. checkOut from # query_Table_Temp a join FileServiceDB. dbo. userInfo B on 1 = 1 where B. active = 1 and B. checkFree = 0 -- select. checkDay,. checkIn,. checkOut, B. userID, B. name, B. defaultDeptID, B. oa_UserID from # query_Table_Temp a join FileServiceDB. dbo. userInfo B on 1 = 1 where B. active = 1 and B. checkFree = 0 update # attend_Temp set checkIn = (select min (checkTime) from OA_checkInOut where userID = # attend_Temp.userID and datediff (minute, checkTime, # attend_Temp.defCheckIn) between-150 and 210) update # attend_Temp set checkOut = (select max (checkTime) from OA_checkInOut where userID = # attend_Temp.userID and datediff (minute, # attend_Temp.defCheckOut, checkTime) between-270 and 690) -- other statements select checkDay, (select count (*) from # attend_Temp where checkDay = # query_Table_Temp.checkDay and checkIn> # query_Table_Temp.checkIn and out1 = 0 and leave1 = 0 and rest = 0 and evection = 0) as latencies (select count (*) from # attend_Temp where checkDay = # query_Table_Temp.checkDay and checkOut <# query_Table_Temp.checkOut and out2 = 0 and leave2 = 0 and rest = 0 and evection = 0) as early departures (select count (*) from # attend_Temp where checkDay = # query_Table_Temp.checkDay and checkIn is null and out1 = 0 and leave1 = 0 and rest = 0 and evection = 0) as persons not registered at work, (select count (*) from # attend_Temp where checkDay = # query_Table_Temp.checkDay and checkOut is null and out2 = 0 and leave2 = 0 and rest = 0 and evection = 0) as not registered after work from # query_Table_Temp drop table # attend_Temp set nocount offendGO
Reply to discussion (solution)
Is msexequery a php function?
I have never met
Oh, it's amazing. it turns out mssql_query is not good. it's okay to change it to odbc_exec. first use odbc_exec.
Msexequery is a packaged function, which originally uses mssql_query.