Say you have a stored procedure called SetCustomerName that has an input parameter name, and I have a client table with a column name. Therefore, in my stored procedure, I want to set the client name. If i write
UPDATE customers SET Name = Name;
this is wrong and I see two other ways:
UPDATE customers SET Name = `Name`; UPDATE customers SET customers.Name = Name;
It works at first, but I did not find in the documentation that I can wrap the parameters inside the `characters. Or I skipped this in the documentation (the link is appreciated in this case).
What other methods exist and what is the standard method for such a case? Renaming an input parameter is not suitable for me (because I have an automatic object-relational mapping if you know what I mean).
UPDATE:
So, there is a link about backticks ( http://dev.mysql.com/doc/refman/5.0/en/identifiers.html ), but it has not sufficiently explained how to use them (how to use them with parameters and column names).
And there is a very strange thing (at least for me): you can use backward measures anyway:
UPDATE customers SET Name = `Name`; //or UPDATE customers SET `Name` = Name; //or even UPDATE customers SET `Name` = `Name`;
and they all work exactly the same.
Don't you think this is weird? Is this strange behavior explained somewhere?
mysql parameters stored-procedures
nightcoder
source share