我正在尝试创建存储过程,但它失败了,我不知道为什么? 请求:
delimiter //
drop procedure if exists sp_edit_booking_owner;
create procedure sp_edit_booking_owner(v_pnr varchar(32), v_login varchar(200))
begin
declare l_iduser int(11) default null;
SELECT id_user INTO l_iduser FROM users WHERE userlogin = v_login;
if l_iduser is not null then
update book set iduser_c = l_iduser where bookingref = v_pnr;
update seg s join book b on s.id_book = b.id_book set s.id_user = l_iduser where b.bookingref = v_pnr;
update segmentown so join seg s on s.id_seg = so.id_seg join book b on s.id_book = b.id_book set so.id_user = l_iduser where b.bookingref = v_pnr;
update historyb hb join seg s on s.id_seg = hb.id_seg join book b on s.id_book = b.idbooking join users u on u.iduser = s.id_user_m set hb.eventowner = u.username where b.bookingref = v_pnr and hb.event not like '%USER%';
update historyb hb join seg s on s.id_seg = hb.id_seg join book b on s.id_book = b.idbook join users u on u.id_user = s.id_user_m set hb.event = concat(u.username, '(USER)') where b.bookingpnr = v_pnr and hb.event like '%USER%';
end if;
end;
//
delimiter ;
这可能是一个合成器问题,但我不知道从哪里来...... 有人有想法吗?
感谢。
答案 0 :(得分:4)
如果更改分隔符,则需要使用它,直到再次更改
delimiter //
drop procedure if exists sp_edit_booking_owner //
create procedure sp_edit_booking_owner(v_pnr varchar(32), v_login varchar(200))
...
修复此问题,我可以在MySQL上使用
创建它答案 1 :(得分:1)
使用此代码:
它的作品;)
delimiter // drop procedure if exists sp_edit_booking_owner// create procedure sp_edit_booking_owner(IN v_pnr varchar(32),IN v_login varchar(200)) begin declare l_iduser int(11) default null; SELECT id_user INTO l_iduser FROM users WHERE userlogin = v_login; if l_iduser is not null then update book set iduser_c = l_iduser where bookingref = v_pnr; update seg s join book b on s.id_book = b.id_book set s.id_user = l_iduser where b.bookingref = v_pnr; update segmentown so join seg s on s.id_seg = so.id_seg join book b on s.id_book = b.id_book set so.id_user = l_iduser where b.bookingref = v_pnr; update historyb hb join seg s on s.id_seg = hb.id_seg join book b on s.id_book = b.idbooking join users u on u.iduser = s.id_user_m set hb.eventowner = u.username where b.bookingref = v_pnr and hb.event not like '%USER%'; update historyb hb join seg s on s.id_seg = hb.id_seg join book b on s.id_book = b.idbook join users u on u.id_user = s.id_user_m set hb.event = concat(u.username, '(USER)') where b.bookingpnr = v_pnr and hb.event like '%USER%'; end if; end// delimiter ;
答案 2 :(得分:0)
感谢您的回复。 事实上,我的第一次请求并没有错。
您只需通过终端(命令行中的mysql)执行此请求。
再次感谢。