CREATE PROCEDURE `createOrderNo_proc`(OUT outValue BIGINT)
NOT DETERMINISTIC
SQL SECURITY DEFINER
COMMENT ''
BEGIN
SET AUTOCOMMIT=0;//JAVA问题查询
select seqValue INTO @value from air_orderNoSeq where seqName = 'ORDERNO' for update;
if (@value is NULL) then
insert into air_orderNoSeq(seqName, seqValue) values('ORDERNO', '10000');
commit;
set outValue = 10000;
else
set @value = @value + 1;
update air_orderNoSeq set seqValue = @value where seqName = 'ORDERNO';
commit;
set outValue = @value;
end if;
END;
调用方法:JAVA问题查询
CALL createOrderNo_proc(@rtn);
SELECT @rtn;