more nodes to b retrived if change in data
hi can some one say.. if i add more values as child this fuction is not working.. can u modify so that it works for any modification in child nodes
create function rtn(@uid int)
returns @output table(userid bigint,roleid bigint)
as
begin
declare @rid int,@pid int
select @rid = ( select roleid from usermaster where userid =@userid)
select @pid = ( select positionid from usermaster where userid=@userid)
if @rid=2
begin
insert @output
select userid,roleid from usermaster
where roleid in(select roleid from rolemaster where parentroleid=
(select roleid from rolemaster where parentroleid=@rid))
and
positionid in
(select positionid from positionmaster where parentpositionid in
(select positionid from positionmaster where parentpositionid=@pid))
end
if @rid>2
begin
insert @output
select userid, roleid from usermaster where userid in
(select positionid from positionmaster where parentpositionid = @uid)
end
return
end
Thanz in adv
ali
|