在一个存储过程里面,首先获得一个唯一的seqid ,然后进行一系列的操作插入到一个表中,表里面有个seqid字段,主要是用于并发操作,
最后在 存储过程里面执行:
select * from xxx where seqid=;
delete from xxx where seqid=;
不知道怎么的,有时候 删除不了数据。但是单个测试就不会存在那情况,都可以删除掉,
最后在 存储过程里面执行:
select * from xxx where seqid=;
delete from xxx where seqid=;
不知道怎么的,有时候 删除不了数据。但是单个测试就不会存在那情况,都可以删除掉,
解决方案 »
- mysql乱码
- codesmith连接postgresql数据库 这个怎么连接 DLL?连接字符串?怎么写?
- 求救关于mysql 还原数据库速度的问题
- 能否在同一台机器起动 两个mysql 服务
- 为什么我的MySql在XP和Win2k下都说访问禁止阿
- 如何实现?
- mysql维护麻烦吗?
- mysql如何更改root的密码?
- 修改后的MySQL数据库操作类修改了之前一些错误,http://www.csdn.net/develop/article/10/10934.shtm
- mysql查询极慢以及锁表问题
- Cannot create PoolableConnectionFactory
- 输出phpinfo显示的信息中为什么没有mysql,是否没配置好?
fn_nextval
UPDATE sequence
SET current_value = current_value + increment
WHERE NAME = seq_name;
RETURN fn_currval(seq_name);
END
fn_currval
BEGIN
DECLARE curVal INTEGER;
SET curVal = 0;
SELECT current_value INTO curVal FROM sequence WHERE NAME = seq_name;
RETURN curVal;
END
fn_nextval
UPDATE sequence
SET current_value = current_value + increment
WHERE NAME = seq_name;
RETURN fn_currval(seq_name);
END
fn_currval
BEGIN
DECLARE curVal INTEGER;
SET curVal = 0;
SELECT current_value INTO curVal FROM sequence WHERE NAME = seq_name;
RETURN curVal;
END
fn_nextval
UPDATE sequence
SET current_value = current_value + increment
WHERE NAME = seq_name;
RETURN fn_currval(seq_name);
END
fn_currval
BEGIN
DECLARE curVal INTEGER;
SET curVal = 0;
SELECT current_value INTO curVal FROM sequence WHERE NAME = seq_name;
RETURN curVal;
END
在存储过程最后写:
select * from xxx where seqid=1111;
delete from xxx where seqid=1111;
这个有什么影响吗?
从你的2个SQL命令,看不出来任何错误。只要seqid 符合记录的,肯定都会删除掉。
你是怎么样测试到有的可以有的不行的??
delete from xxxx where SeqId=seqNum;
declare tmsid varchar(50) ;
DECLARE depthid int ;
DECLARE seqNum int ;
set depthid=0;
set seqNum=global_equity.fn_nextval('TREE');
insert into xxxx(
SeqId,
MSId,
MSName,
ShortName,
ParentId,
IndustryType,
TableType,
IsHide,
LevelId
)
select
seqNum,
MSId,
MSName,
ShortName,
ParentId,
IndustryType,
TableType,
IsHide,
depthid
from yyy where ParentId=i_msId and IndustryType=i_industryType ;WHILE ROW_COUNT()>0 DO
set depthid=depthid+1;
insert into xxxx(
SeqId,
MSId,
MSName,
ShortName,
ParentId,
IndustryType,
TableType,
IsHide,
LevelId
)
select
seqNum,
a.MSId,
a.MSName,
a.ShortName,
a.ParentId,
a.IndustryType,
a.TableType,
a.IsHide,
depthid
from yyy a,xxxx b
where a.ParentId=b.MSId
and b.LevelId=depthid-1
and a.IndustryType=i_industryType;
END WHILE;select * from xxxx where SeqId=seqNum;
delete from xxxx where SeqId=seqNum;