mysql 建立传表名的参数,存储过程没出错,但是调用的时候显示错误如下 5

[SQL]callPRO_NCOMPCODE('sw_dt_sk_basicinfo','sw_basic_new_company_id');[Err]1064-Youh... [SQL] call PRO_NCOMPCODE('sw_dt_sk_basicinfo','sw_basic_new_company_id');
[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NULL' at line 1
CREATE DEFINER = `root`@`localhost` PROCEDURE `NewProc`(IN TAB_NCODE VARCHAR(50),IN TAB_COMID VARCHAR(50))
BEGIN
start TRANSACTION;
set @sqlcm:=concat("UPDATE ",TAB_NCODE," SET ",TAB_NCODE,".NCOMPCODE=",TAB_COMID,".new_comp_id "
" where ",TAB_NCODE,".SYMBOL=",TAB_COMID,".SYMBOL"
" and (",TAB_NCODE,".NCOMPCODE is NULL OR LENGTH(",TAB_NCODE,".NCOMPCODE)=0)");
prepare stmt from @sqlcmd;
execute stmt;
COMMIT;
end;
展开
 我来答
森林的沉睡
2016-04-28 · TA获得超过297个赞
知道小有建树答主
回答量:179
采纳率:85%
帮助的人:158万
展开全部
把sqlcm的值改下
set  @sqlcm:=concat("UPDATE ",TAB_NCODE,",",TAB_COMID ," SET ",TAB_NCODE,".NCOMPCODE=",TAB_COMID,".new_comp_id "
" where ",TAB_NCODE,".SYMBOL=",TAB_COMID,".SYMBOL"
"  and (",TAB_NCODE,".NCOMPCODE is NULL OR LENGTH(",TAB_NCODE,".NCOMPCODE)=0)");


做拼接在调试阶段建议在set @sqlcm之后,加上:

SELECT @sqlcm;

这样在call时就可以看到中间结果了.

推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式