刚用 Mysql 写存储过程,但是一直没通过,请各位帮忙看看:
CREATE PROCEDURE del_user(param1 varchar(10),param2 varchar(40),out param3 tinyint)declare a int;
select count(*) into a from e_user where ur_user_id=param1;
if a=0 then
begin
set param3=2;
return;
end;begin transaction
begindeclare flag1,flag2,flag3 int; delete from e_user where ur_user_id=param1;
set @flag1=@@error;
delete from e_user_fun where uf_user_id=param1;
set @flag2=@@error;
insert into e_tran_log values(getdate(),'SYS_USER and SYS_USER_FUN',param2,'Delete','Delete SYS User :'+param1);
set @flag3=@@error; if @flag1=0 and @flag2=0 and @flag3=0 then
begin
commit transaction;
set param3=1;
return;
end;
rollback transaction;
set param3=0;
return;
end;Error 1064<42000>: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
'declare a int;
select count(*) into a from e_user where ur_user_id=param1;
'at line 2
CREATE PROCEDURE del_user(param1 varchar(10),param2 varchar(40),out param3 tinyint)declare a int;
select count(*) into a from e_user where ur_user_id=param1;
if a=0 then
begin
set param3=2;
return;
end;begin transaction
begindeclare flag1,flag2,flag3 int; delete from e_user where ur_user_id=param1;
set @flag1=@@error;
delete from e_user_fun where uf_user_id=param1;
set @flag2=@@error;
insert into e_tran_log values(getdate(),'SYS_USER and SYS_USER_FUN',param2,'Delete','Delete SYS User :'+param1);
set @flag3=@@error; if @flag1=0 and @flag2=0 and @flag3=0 then
begin
commit transaction;
set param3=1;
return;
end;
rollback transaction;
set param3=0;
return;
end;Error 1064<42000>: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
'declare a int;
select count(*) into a from e_user where ur_user_id=param1;
'at line 2
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货