我尝试为我的存储过程执行以下代码,并在第14行引发错误。我无法找到错误,帮我解决。
DELIMITER $$
CREATE PROCEDURE usp_SetGems (
-- Add the parameters for the stored procedure here
p_requestid int/* =null */,
p_akcija int/* =null */)
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
-- Insert statements for procedure here
if p_akcija = 0 then
declare @v_userId char(36);
declare @v_vingems int;
select @v_userId:=r.user_id, @v_vingems := r.value from Requests r
where r.Id=p_requestid;
update Users
set balance=balance+@v_vingems
where id=v_userId;
else
declare @v_userrId longtext;
declare @v_vingemss int;
select @v_userrId.user_id:=r.user_id, @v_vingemss := r.value from Requests r
where r.Id=p_requestid;
update Users
set balance=balance-@v_vingems
where id=v_userrId;
end if;
end; $$
DELIMITER ;
答案 0 :(得分:0)
您的选择中有一个保留字。 "到"
...
environment:
- USERID=$USERID
答案 1 :(得分:0)
你的Declare语句是错误的(声明@v_userId char(36),声明@v_vingems int; .....)。以下是您的程序的正确代码: -
DELIMITER $$
CREATE PROCEDURE usp_SetGems (
-- Add the parameters for the stored procedure here
p_requestid int/* =null */,
p_akcija int/* =null */)
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
-- Insert statements for procedure here
if p_akcija = 0 then
BEGIN
select r.user_id, r.value INTO @v_userId, @v_vingems from Requests r
where r.Id=p_requestid;
update Users
set balance=balance+@v_vingems
where id=v_userId;
END;
else
BEGIN
select r.user_id, r.value INTO @v_userId, @v_vingems from Requests r
where r.Id=p_requestid;
update Users
set balance=balance-@v_vingems
where id=v_userrId;
END;
end if;
end $$
DELIMITER ;