Hi
I found this thread trying to solve the same issue - using recursive SQL in sparx.
I appreciate this is a bit late to the table (no pun intended) but I solved this dilemma by creating a table function and then using it in Sparx. Here is an example function that takes a parameter
1. returns all objects that contain the characters.
2. Returns the package name hierarchy and the depth of each object.
You can right-click any object returned and locate in diagrams/browser etc.
--drop function dbo.ufn_find_name
create function dbo.ufn_find_name (@pName nvarchar(255))
returns @retSPack table
(
CLASSGUID nvarchar(40),
object_type nvarchar(255),
Name nvarchar(255) not null,
Stereotype nvarchar(255) null,
PackageName varchar(8000) not null,
level int not null
)
-- Returns the set of objects that match the contain @pName in the object name
-- and the package hierarchy they reside in
as
begin
with package_levels (ea_guid,object_type,Name,parent_id,Stereotype,PackageName,level)
as(
select c.ea_guid,c.object_type,c.name as Name, package.parent_id, c.stereotype as Stereotype,cast(package.name as varchar(8000)) as PackageName,0
from t_object c inner join t_package as package on c.package_id = package.package_id
where (c.NAME like '%' + @pName + '%')
union all
select c.ea_guid,c.object_type,c.name as Name, package.parent_id, Stereotype,cast(concat(package.name,' / ',c.PackageName ) as varchar(8000)) as PackageName, level + 1
from package_levels c inner join t_package as package on c.parent_id = package.package_id
)
insert @retSPack
select distinct ea_guid,object_type,Name,Stereotype,PackageName,level
from package_levels pl
where pl.parent_id=0
return
end;
To use the function in sparx:
select *
from dbo.ufn_find_name('employer')
where packagename not like 'sand%'
/*and stereotype like '%role%'*/
order by name, packagename
HTH
Rob