2 ship987654 ship987654 于 2014.04.12 16:41 提问

将以下的sqlserver的函数写成oracle的函数怎么改?

ALTER function [dbo].getSubDepartment)
returns @tabinfo table(deptid NUMERIC(20),deptname varchar(100),parentid numeric(20),level int)
as
begin
declare @cid int
set @cid = 1

insert @tabinfo 

select deptid,deptname,parentid,@cid from DEPARTMENT where deptid = @deptid

while @@rowcount>0
begin
set @cid = @cid + 1

    insert @tabinfo 
    select distinct ta.deptid,ta.deptname,ta.parentid,@cid
    from DEPARTMENT as ta join @tabinfo as tb
    on ta.parentid = tb.deptid
    where tb.level = @cid-1
end
return

end

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!