Details
-
Type:
Bug
-
Status: Closed
-
Resolution: Incomplete
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: None
-
Labels:
Description
I have a very simple table like this:
CREATE TABLE `path` (
`PID` int(10) unsigned NOT NULL,
`PPath` varchar(2000) NOT NULL,
`PHash` binary(16) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB;
And a SP:
create procedure test(path VARCHAR(2000))
begin
DECLARE pid INT UNSIGNED;
DECLARE hash BINARY(16) DEFAULT UNHEX(MD5(path));
SELECT PID FROM path LIMIT 1;
end|
call test("/")|
Calling the procedure test() returns NULL. Upper and lower case doesn't matter. Renaming the column to something different like
alter table path change PID id int unsigned;
returns the correct result.
Gliffy Diagrams
Attachments
Activity
- All
- Comments
- Work Log
- History
- Activity
- Transitions
Re: Column name PID returns NULL when called via SP
Hi,
Is it still a problem?
From what I see in your code, you redefine pid in your procedure (without assigning a value to it), so PID in the SELECT is the variable name, not the column name. When you rename the column into something else, it is not masked any longer, so a value from the table is returned. Alternatively, you could provide the full name in SELECT (SELECT path.PID FROM path LIMIT 1).
Do you have a reason to expect different behavior?