【发布时间】:2017-02-11 05:44:11
【问题描述】:
我一直在试图弄清楚我在 beloe 程序中做错了什么
CREATE PROCEDURE `example`(IN col_n char(50),IN p_cont char(50),IN p_ud int)
BEGIN
set @S = CONCAT('select rn.emp_id as emp_id,controller,perma,permb,permc,permd,order from emp n
join resource_emp rn on rn.emp_id = n.emp_id
join resource r on r.resource_id = rn.resource_id
join u_resource ur on ur.resource_id = r.resource_id
join user u on u.u_id = ur.ur_id
join(
select title,min(order) as pr from emp n
join resource_emp rn on rn.emp_id = n.emp_id
join resource r on r.resource_id = rn.resource_id
join u_resource ur on ur.resource_id = r.resource_id
join user u on u.u_id = ur.ur_id
where u.u_id = ',@p_ud,' group by title)a on a.title = n.title and a.pr = order
where u.u_id = ',@p_ud,' n.con = ''',@p_cont,''' and ,@col_n,' = 1
group by n.title order by n.order');
PREPARE stmt1 FROM @S;
EXECUTE stmt1;
DEALLOCATE PREPARE stmt1;
END
我正在尝试执行以下过程但出现错误
call hop_thlc_t.auth('perma', 'submit', 2);
错误代码:1064。您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 1 行的“NULL”附近使用正确的语法
虽然发生这种情况,但我仍然可以通过使用以下参数将上述过程作为查询运行并获得所需的结果
set @col_n ='perma';
set @p_cont = 'submit' ;
set @p_ud =2;
感谢任何解决问题的帮助
【问题讨论】:
-
你在所有参数前添加了@,删除它们怎么样?
-
嗨,当您在参数列表中使用
@p_cont时,我在您的查询中看到了@p_con。 -
错字,已更正
标签: mysql stored-procedures mysql-workbench