Bug #64349 | SELECT ... WHERE column IN (S.P. Parameter List) returns incomplete result | ||
---|---|---|---|
Submitted: | 16 Feb 2012 8:22 | Modified: | 17 Feb 2012 5:01 |
Reporter: | David Berg | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: Stored Routines | Severity: | S3 (Non-critical) |
Version: | 5.5.20 and earlier | OS: | Windows (XP Pro SP3) |
Assigned to: | CPU Architecture: | Any |
[16 Feb 2012 8:22]
David Berg
[16 Feb 2012 11:09]
Valeriy Kravchuk
If you need to build (parts of) SQL statements dynamically, why not to use prepared statements in your stored procedure? Check http://dev.mysql.com/doc/refman/5.5/en/sql-syntax-prepared-statements.html for details.
[16 Feb 2012 18:47]
David Berg
Valeriy, Thank you for your suggestion. I definitely would have done that, except the values returned by the particular SELECT in my procedure are used in a cursor to iterate through a block of code for each value ... and cursors may not contain prepared statements. My workaround in this case was to use a prepared statement to insert the values into a temporary table and declare a cursor to select from the temporary table.
[17 Feb 2012 5:01]
Valeriy Kravchuk
Yes, you need some other approach/workaround, as IN ('1,2,3') condition will never evaluate the way you expect. You pass single string value with commas inside this way, not 3 numbers.