At 17:15 -0400 4/8/05, Paul Beer wrote:
I'm trying to pass a value into a stored procedure to dynamically set
which column(s) to sort by. The following code doesn't work.
The query executes but ignores my order by parameter.
I assume there is a simple answer to this that I'm just missing.
Yes. Unfortunately, the simple answer is that you can't do it.
Parameters are for data values, not column names.
(You'll encounter a similar problem in many database APIs if you
try to use a parameter in a prepared statement for anything but a
data value.)
create procedure sp_equipment_find (
IN L_ORDER_BY MEDIUMTEXT
)
BEGIN
SELECT * from mytable ORDER BY @L_ORDER_BY;
END$
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]
--
Paul DuBois, MySQL Documentation Team
Madison, Wisconsin, USA
MySQL AB, www.mysql.com
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]