下面是我写的一个存储过程,大侠们帮我看看,有什么不对?我在线,散分了!谢谢
create procedure f_get_next_table_id (out p_id int, in name1 varchar(50))
begin
DECLARE p_id int;
DECLARE numcount int;
select count(1) as numcount from sequence_table where stridname=name1;
if (numcount <1) then
insert into sequence_table(stridname,intvalue) values(name1,10000);
end if;
select intvalue into p_id from sequence_table where stridname=name1 for update;
update sequence_table set intvalue=intvalue+1 where stridname=name1;
commit;
return p_id;
end;
// 创建一个表sequence_table 专门用来存序列,存放数据库其他表的序列,如果没有,就增加,
但是我运行老是编译都不能通过,求高手帮我解答下,谢谢。
create procedure f_get_next_table_id (out p_id int, in name1 varchar(50))
begin
DECLARE p_id int;
DECLARE numcount int;
select count(1) as numcount from sequence_table where stridname=name1;
if (numcount <1) then
insert into sequence_table(stridname,intvalue) values(name1,10000);
end if;
select intvalue into p_id from sequence_table where stridname=name1 for update;
update sequence_table set intvalue=intvalue+1 where stridname=name1;
commit;
return p_id;
end;
// 创建一个表sequence_table 专门用来存序列,存放数据库其他表的序列,如果没有,就增加,
但是我运行老是编译都不能通过,求高手帮我解答下,谢谢。
delimiter //
create procedure f_get_next_table_id (out p_id int, in name1 varchar(50))
begin
DECLARE p_id int;
DECLARE numcount int;
select count(1) into numcount from sequence_table where stridname=name1;
if (numcount <1) then
insert into sequence_table(stridname,intvalue) values(name1,10000);
end if;
select intvalue into p_id from sequence_table where stridname=name1 for update;
update sequence_table set intvalue=intvalue+1 where stridname=name1;
commit;
select p_id;
end//
delimiter ;