From: Peter Brawley Date: May 26 2010 3:35pm Subject: Re: Impossible Out Param Return Value List-Archive: http://lists.mysql.com/mysql/221717 Message-Id: <4BFD3FB1.4070704@earthlink.net> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="------------090805010409010202060506" --------------090805010409010202060506 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Kevin, >The problem occurs because the parameter names are the same as the column names. >I'm not sure why, since the columns are specified in quotes, but it does. Eh? Backticks merely permit use of reserved words as identifiers. PB ----- On 5/26/2010 9:56 AM, Kevin Baynes wrote: > > The problem occurs because the parameter names are the same as the column names. I'm not sure why, since the columns are specified in quotes, but it does. > > Thanks, > > Kevin > > -----Original Message----- > From: Kevin Baynes [mailto:KBaynes@stripped] > Sent: Wednesday, May 26, 2010 10:07 AM > To: mysql@stripped > Subject: Impossible Out Param Return Value > > > Using MySql 5.1, I have a very simple table with 1 row. I have a Stored Procedure to select if the row exists. I expect the test of this SP to return null, but it returns a value! The value is always returned if the 'path' matches, regardless of the other values being tested. If the 'path' does not match, it returns NULL as expected. Has anyone seen this before? > > Thanks, > Kevin > > -- > Full explanation below: > -- > > Table 'file_detail' with 1 row: > > id_file_detail, id_file, id_machine, id_user, path > 1 , 1 , 1 , 1 , C:\Program Files\BlueZone > > -- > Stored Procedure to see if row exists: > -- > > DROP PROCEDURE IF EXISTS `find_file_detail`$$ > CREATE PROCEDURE `find_file_detail` > ( > IN id_file int(11), > IN id_machine int(11), > IN id_user int(11), > IN filePath varchar(255), > OUT keyOut int(11) > ) > BEGIN > > SELECT `id_file_detail` > INTO keyOut > FROM `file_detail` > WHERE (`id_file` = id_file > AND `id_machine` = id_machine > AND `id_user` = id_user > AND `path` = filePath) > LIMIT 1; > > END$$ > > -- > SQL used to test the stored procedure: > -- > > SET @keyOut = NULL; > CALL find_file_detail(99,99,99,'C:\\Program Files\\BlueZone',@keyOut); > SELECT @keyOut; > > -- > > Notice there is 1 row, the values of 99 do not exist, but the path does exist. This test will return @keyOut = 1. How is this possible? > > If I change the path string to use 'BlueZone1' (so the paths do not match), then this test will return @keyOut = NULL as expected. It seems as though the only thing getting matched is the path and the other 3 values are being ignored. > > Does this make sense to anyone? > > Kevin Baynes > Senior Software Developer > Rocket Software > > > > > > > No virus found in this incoming message. > Checked by AVG - www.avg.com > Version: 8.5.437 / Virus Database: 271.1.1/2897 - Release Date: 05/26/10 06:25:00 > > --------------090805010409010202060506--