随便改了改,没测试 CREATE PROCEDURE 新亿迪BBS表节点del @pi_帖子号 int,@po_SqlCode int as declare @brother_帖子号 int,@father_帖子号 int,@start_显示次序 int,@end_显示次序 int BEGIN select @po_SqlCode = 0 select @father_帖子号=case when 父接点 is NULL then -1 else 父接点 end, @start_显示次序=显示次序 from 新亿迪BBS表 WHERE 帖子号 = @pi_帖子号 if @father_帖子号 = -1 then -- 该节点为根节点 delete from 新亿迪BBS表 where 根接点号 = @father_帖子号 or 帖子号 = @father_帖子号 else begin select @end_显示次序=min(显示次序) from 新亿迪BBS表 WHERE 父接点 = @father_帖子号 and 显示次序 > @start_显示次序 if @end_显示次序 is null then delete from 新亿迪BBS表 where 父接点 = @father_帖子号 and 显示次序 >= @start_显示次序 else delete from 新亿迪BBS表 where 父接点 = @father_帖子号 and 显示次序 >= @start_显示次序 and 显示次序 < @end_显示次序 end select @@error return END 新亿迪BBS表节点del
不行啊:(提示then else附近有错,请帮帮忙解决这个问题!!
是多了then,再试试 CREATE PROCEDURE 新亿迪BBS表节点del @pi_帖子号 int,@po_SqlCode int as declare @brother_帖子号 int,@father_帖子号 int,@start_显示次序 int,@end_显示次序 int BEGIN select @po_SqlCode = 0 select @father_帖子号=case when 父接点 is NULL then -1 else 父接点 end, @start_显示次序=显示次序 from 新亿迪BBS表 WHERE 帖子号 = @pi_帖子号 if @father_帖子号 = -1 -- 该节点为根节点 delete from 新亿迪BBS表 where 根接点号 = @father_帖子号 or 帖子号 = @father_帖子号 else begin select @end_显示次序=min(显示次序) from 新亿迪BBS表 WHERE 父接点 = @father_帖子号 and 显示次序 > @start_显示次序 if @end_显示次序 is null delete from 新亿迪BBS表 where 父接点 = @father_帖子号 and 显示次序 >= @start_显示次序 else delete from 新亿迪BBS表 where 父接点 = @father_帖子号 and 显示次序 >= @start_显示次序 and 显示次序 < @end_显示次序 end select @@error return END 新亿迪BBS表节点del
CREATE PROCEDURE 新亿迪BBS表节点del @pi_帖子号 int,@po_SqlCode int
as
declare @brother_帖子号 int,@father_帖子号 int,@start_显示次序 int,@end_显示次序 int
BEGIN
select @po_SqlCode = 0
select @father_帖子号=case when 父接点 is NULL then -1 else 父接点 end, @start_显示次序=显示次序
from 新亿迪BBS表 WHERE 帖子号 = @pi_帖子号
if @father_帖子号 = -1 then -- 该节点为根节点
delete from 新亿迪BBS表 where 根接点号 = @father_帖子号 or 帖子号 = @father_帖子号
else
begin
select @end_显示次序=min(显示次序) from 新亿迪BBS表 WHERE 父接点 =
@father_帖子号 and 显示次序 > @start_显示次序
if @end_显示次序 is null then
delete from 新亿迪BBS表 where 父接点 = @father_帖子号 and 显示次序 >= @start_显示次序
else
delete from 新亿迪BBS表 where 父接点 = @father_帖子号 and 显示次序 >= @start_显示次序
and 显示次序 < @end_显示次序
end
select @@error
return
END 新亿迪BBS表节点del
CREATE PROCEDURE 新亿迪BBS表节点del @pi_帖子号 int,@po_SqlCode int
as
declare @brother_帖子号 int,@father_帖子号 int,@start_显示次序 int,@end_显示次序 int
BEGIN
select @po_SqlCode = 0
select @father_帖子号=case when 父接点 is NULL then -1 else 父接点 end, @start_显示次序=显示次序
from 新亿迪BBS表 WHERE 帖子号 = @pi_帖子号
if @father_帖子号 = -1 -- 该节点为根节点
delete from 新亿迪BBS表 where 根接点号 = @father_帖子号 or 帖子号 = @father_帖子号
else
begin
select @end_显示次序=min(显示次序) from 新亿迪BBS表 WHERE 父接点 =
@father_帖子号 and 显示次序 > @start_显示次序
if @end_显示次序 is null
delete from 新亿迪BBS表 where 父接点 = @father_帖子号 and 显示次序 >= @start_显示次序
else
delete from 新亿迪BBS表 where 父接点 = @father_帖子号 and 显示次序 >= @start_显示次序
and 显示次序 < @end_显示次序
end
select @@error
return
END 新亿迪BBS表节点del