Sybase 代替start with、connect by的store procedure
来源:互联网 发布:mac电脑照片怎么整理 编辑:程序博客网 时间:2024/04/29 08:14
if exists (select 1 from sysobjects where type='P' and name ='tree_p_lujn')
DROP PROC tree_p_lujn
go
create proc tree_p_lujn(
@is_root_start_id varchar(100),
@is_table_name varchar(100),
@is_colume_id_name varchar(100),
@is_colume_parent_id_name varchar(100)
)
as
declare
@vn_pointer int,
@vn_lsmore int,
@vs_sql_temp varchar(2000)
begin
set @vs_sql_temp ="
create table #tmp(pid int not null,id int not null ,curr int not null,le varchar(255) not null)
insert into #tmp
select 0,convert(int,t."+@is_colume_id_name+"),0,'.'+convert(varchar,t."+@is_colume_id_name+")
from "+@is_table_name+" t
where t."+@is_colume_parent_id_name+" ='"+@is_root_start_id+"'
set @vn_lsmore=@@rowcount,@vn_pointer=0
while(@vn_lsmore>0)
begin
insert into #tmp
select convert(int,t."+@is_colume_id_name+"),convert(int,t."+@is_colume_id_name+"),
@vn_pointer+1,u.le+'.'+convert(varchar,t."+@is_colume_id_name+")
from "+@is_table_name+" t,#tmp u
where convert(int,t."+@is_colume_parent_id_name+")=u.id and u.curr=@vn_pointer
set @vn_pointer=@vn_pointer+1,@vn_lsmore=@@rowcount
end
select t.* from "+@is_table_name+" t,#tmp u
where u.id=convert(int,t."+@is_colume_id_name+") order by le"
print @vs_sql_temp
exec (@vs_sql_temp)
return
end
----------测试-------------
exec tree_p_lujn '0','TBL_TEST','ID','PID'
- Sybase 代替start with、connect by的store procedure
- start with connect by
- start with connect by
- start with connect by
- connect by/start with
- start with connect by
- connect by...start with...的使用
- Oracle Start With Connect By 的用法
- start with ...connect by的用法
- start with 和 connect by 的用法
- connect by prior... start with的使用
- oracle 的 CONNECT BY 和START WITH
- Oracle 的 start with connect by 用法
- oracle 的 start with connect by 用法 .
- oracle的start with connect by语句
- Oracle数据库的start with ... connect by
- connect by prior start with
- connect by prior start with
- WPF布局
- ASP.NET绑定学习
- AJAX+Js实现html页面点击数自动更新
- 下载
- Getting the Dimensions of Text:获取文本的长和宽
- Sybase 代替start with、connect by的store procedure
- 静态资源(StaticResource)和动态资源(DynamicResource)
- 靳氏DIV布局兼容“武林秘诀”
- BSD net源码分析(1)
- Java的SCWCD认证考什么(含真题以及考点分析)
- [AutoIt]发送SMTP邮件,支持附件
- WPF体系结构
- Magento设计人员手册
- 应用SSH开发(Eclipse5.0)