在MySQL存储过程中将FieldName作为参数传递 [英] Passing FieldName as Parameter in MySQL Stored Procedure

查看:72
本文介绍了在MySQL存储过程中将FieldName作为参数传递的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将表字段名称作为参数传递给存储过程,但是存储过程将字段名称作为值而不是字段名称,并抛出错误.

I am passing table field name as parameter to stored procedure but stored procedure take field name as value instead of field name and throws error.

例如,如果我通过参数FieldName传递了isEnabled值,则Mysql会在字段列表中引发错误未知列'isEnabled',这表明mysql自动添加了引号.

e.g if i pass value isEnabled via parameter FieldName, Mysql throws error unknown column 'isEnabled' in field list, which shows mysql automatically add quote.

这是我编写的示例存储过程.

Here is sample stored procedure i wrote.

CREATE `VSK_Comments_UpdateAction`(IN FieldName varchar(30),IN FieldValue tinyint,CID bigint)
BEGIN
Update comments Set FieldName=FieldValue WHERE commentid=CID;
END;

有没有办法让我正确正确地动态传递字段名称.

Is there is a way so i can properly pass field name dynamically properly.

推荐答案

您可以使用 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆