存储过程的写发表结构还有要显示的格式有关.关于注释的语句: select @current=child //为什么是@current放在前面? from #stack where level1=@level 这是从表里查出内容放到变量的写法.
begin if exists(select * from #stack where level1 =@level)--存在给定层 begin select @current=child //为什么是@current放在前面? from #stack --把#stack表里查找出的child 字段的值赋给变量@curre where level1=@level insert tree--从#stack中找该层的信息(上下结点)送到TREE表里 select @n,child,parent,level1 from #stack where level1=@level and child=@current delete from #stack---从#stack中找删除该层的记录 where level1=@level and child=@current insert #stack---插入下一层记录(来自ABC表) select id1,sx,@level+1 from abc where sx=@current if @@rowcount>0---如果插入了一条以上
select @level=@level+1--层次递进 select @n=@n+1 end else---不存在该层,减一 select @level=@level-1 end
,,,,,,我是做MySql的,所以看了存储过程就ft~~~~~
insert #stack---插入下一层记录(来自ABC表) select id1,sx,@level+1 from abc where sx=@current sx就是叶子的父节点序号呀!!
CREATE PROCEDURE mytanghulu(@child char(10)) ASdrop table mytanghulu1 delcare @abc,@level2 int,@n int select @abc=sx from abc where id1=@child我先写一点,以为抛砖引玉!
select @current=child //为什么是@current放在前面?
from #stack
where level1=@level
这是从表里查出内容放到变量的写法.
if exists(select * from #stack where level1 =@level)--存在给定层
begin
select @current=child //为什么是@current放在前面?
from #stack --把#stack表里查找出的child 字段的值赋给变量@curre
where level1=@level
insert tree--从#stack中找该层的信息(上下结点)送到TREE表里
select @n,child,parent,level1
from #stack
where level1=@level and child=@current
delete from #stack---从#stack中找删除该层的记录
where level1=@level and child=@current
insert #stack---插入下一层记录(来自ABC表)
select id1,sx,@level+1
from abc
where sx=@current
if @@rowcount>0---如果插入了一条以上
select @level=@level+1--层次递进
select @n=@n+1
end
else---不存在该层,减一
select @level=@level-1
end
select id1,sx,@level+1
from abc
where sx=@current
sx就是叶子的父节点序号呀!!
ASdrop table mytanghulu1
delcare @abc,@level2 int,@n int
select @abc=sx from abc where id1=@child我先写一点,以为抛砖引玉!
一边去!其实就是改装一下上面的。衷心感谢我的两个朋友
andyting(andyting)(农夫山泉)
jsyzwx(王祥) 并且,我非常尊重二位高手:
: N_chow(一劍飄香)、 OpenVMS(半知半解)、Yang_(扬帆破浪)
感谢你们!
我的问题已经解决。本来想贴上来,谁想,刚刚脾气发作时,竟然被扣了分,想想,
其实没许多人是真要解决问题的,所以不能体谅搞不定的心情 ,虽然,不理我是应该,回答了,我应该感谢。但是,我实在讨厌灌水,没必要算了。
存储过程 OpenVMS(半知半解) 老兄已经说明的很清楚了.我感兴趣的是你用什么语言实现显示tree结构图.