Skip to content
Advertisement

MYSQL Error #1415 on Function Creation: Not allowed to return a result set from a function

Trying to create a conditional-based function that will return a result. I don’t if it’s the way I am setting the result value that is causing the error? Making MySQL throw the error code 1415 Not allowed to return a result set from a function.

Advertisement

Answer

your code has multiple problems, but the bggest ist that you a using a “normal select, which would return a result set, which is not allowed.

so oyu can only use, SELECT .. INTO..FROM..WHERE to get rid of the error message.

Iyour return Value doesn’t correspond with the variable ‘outputResthey must be f the same datatype

MySQL 8 also wants a DETERMINIsTIC added

Below you see a working code sample, so that you can go from here, to whereever you want

| GetTechFull(0,1) |
| :--------------- |
| t testlast       |
| GetTechFull(1,1) |
| :--------------- |
| t Testlast       |

db<>fiddle here

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement