-
Notifications
You must be signed in to change notification settings - Fork 375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SQLSTATE[IMSSP]: The active result for the query contains no fields. #507
Comments
Hi @dipens, could you provide a complete repro script for this error, the stored procedure you are using, and parameters that trigger the error? Thanks |
Sure @david-puglielli and I apologize for the delay in my reply. Here is the complete repro.
The PHP script is the same as mentioned above. As you can see in the stored procedure, there is an IF...ELSE condition in which the first IF returns one record at the end. This is where the method is working fine and everything is being returned as it should. However in the second part, there is nothing being returned except for the simple UPDATE statement. Please let me know if any other information is required. Thank you for your time. |
Hi @dipens, I am having trouble reproducing this issue, and I suspect it's because I'm not using the correct table design. Could you please provide the table schema for the tables referenced in the stored procedure? Thanks. |
Hello @david-puglielli I have tried this with a very basic test table as well and the issue still exists so I doubt its the table design that's causing this. However, I do realize now that I posted code which was relevant to PHP but not Symfony (where I am facing this). This is my Symfony version of the code: (I apologize for this)
And nevertheless, as requested, I am also providing you table design with the very barebone Stored Procedure: Stored Procedure:
Table Structure:
I have tried with this barebone structure and I am able to reproduce the issue. Please let me know if any more information is required. Thank you for your time and I apologize for the confusion above. |
Thank you @dipens, I have one more question for you. Does the issue occur without symfony? For example using the PHP snippet you provided in the first post? Without using symfony, I am getting a different error, using the following:
The output is the following:
The error message is from the |
Hello @david-puglielli, I tried this and this is what I got:
for both type of inputs (in the if loop I used However while testing this if I removed the line
However when I tried to run the else part, it threw the same error again:
Could this line |
Since there is only one row in the result set, calling Could you let us know what version of the PHP drivers are you using, and what version of the ODBC driver too? |
Here is the driver information: msodbcsql/xenial,now 13.0.1.0-1 amd64 [installed] |
Curiously, I can get the error message when hitting the 'else' part of the procedure, but only if I do not call What version of the PDO_SQLSRV driver are you using? You can find out by running |
Not sure how that happened. All I did was follow instructions from here However in my
|
I think you accidentally left the period at the end - |
Sorry you are right. This is the result
|
Sorry I didn't realize there was a new version out already. I have updated to the new version, rebooted the server, restarted Apache already. However, the issue still persists. i.e.
No results whatsoever when using |
The behaviour you observe is identical to what I get now, but it is a bug - the error message is expected when the result set is empty, but the lack of error message after calling Thank you @dipens for letting us know about this! |
Hi, maybe late question, I have gradually always updated on our dev-area to the latest version, since i updated to Latest Version this exact same error happens to us. When i downgrade back to the previous version, our system works fine. Sorry for my English is not the best but, is this considered a bug and could you clarify "We will address this in due course." |
@dipens You're getting In the In the So say you don't know whether or not the stored procedure will go to the
|
@v-kaywon I get what you said which is what I and @david-puglielli were discussing before. But however note that in my original code, I use Symfony, Doctrine, Dbal and the likes and not core PHP. You can find that comment here. My original code looks something like this:
In this case, I don't have an option to check, the Can you please look into when you have the time? Thanks. |
@dipens , may I ask you what behavior are you expecting? Let's say we're not using the stored procedure, and we are just running the query
What are you expecting the result to be? Since the query is just an update, the result set should be null, and you're trying to If you're looking for a way to not return an error, I advise you to change your stored procedure to something like the following:
Now the |
Hello @v-kaywon In that case, I am not expecting anything. I am just expecting it to not return an error. On my old server where I had freeTDS installed, this wasn't an issue. The workaround that you showed, I could always do that. But I have a lot of stored procedures to go through to change this because earlier I didn't need to worry about returning something and freeTDS would not return me any error if there were no records returned. |
@dipens In the PDO_SQLSRV driver, we can set the ERRMODE to SILENT ( Please understand that different drivers behave differently and different customers want different features. You may expect this to not return an error but others may. Our driver has many API's that allow you to workaround your problem but it is unfortunate that Doctrine does not support them. |
@v-kaywon Fair enough. Now atleast that I know the problem and workaround for this, and since its not a bug, the only option that I have is handling it on the Stored Procedure level. Thanks for your time. Closing this issue. |
The trick is to use "SET NOCOUNT ON" before calling the procedure. I found this here |
I have this very simple stored procedure execution on my server setup (SQL Server 2012 on a Windows Server connected to Ubuntu 16.04 running Symfony 3.3 on PHP 7.1 using these drivers ofcourse)
This works fine when there are records being returned. but sometimes depending on the parameters, the stored procedure returns no records. That's when I get this error:
I have already looked into here, here, here, and in issues here too but couldn't find a solution. I have already set
SET NOCOUNT ON
in the beginning of the stored procedure.Is there anything I am missing here or is this a bug?
The text was updated successfully, but these errors were encountered: