Sparx Systems Forum

Enterprise Architect => General Board => Topic started by: Hartmut Jung on June 21, 2011, 08:56:59 pm

Title: Usage of the Macro #Branch#
Post by: Hartmut Jung on June 21, 2011, 08:56:59 pm
Hallo,

we are using the Enterprice Architect Corporate Edition Version 9.0.905.

We want to create and modify user defined SQL-Queries in Context to the selected Object Tree View -Element.

Something like SELECT ea_guid AS CLASSGUID, Object_Type AS CLASSTYPE, Name, note  FROM t_object where t_object.Package_ID like #Branch#;

But this is not working and was looking for an example of the usage of Macro #Branch#. Could you please provide such an example.

Any help is most welcome.

With thanks and best regards

Hartmut Jung
Title: Re: Usage of the Macro #Branch#
Post by: Geert Bellekens on June 21, 2011, 09:06:23 pm
Hartmut

Following query uses both #Package# as #Branch#
Code: [Select]
select c.ea_guid as CLASSGUID,c.object_type as CLASSTYPE,c.name as Name, c.stereotype as Stereotype  ,package.name as 'Package Name',package_p1.name as 'Package level -1',package_p2.name as 'Package level -2',package_p3.name as 'Package level -3' from
t_object c join t_package as package on (c.package_id = package.package_id) left join t_package as package_p1 on (package_p1.package_id = package.parent_id) left join t_package as package_p2 on (package_p2.package_id = package_p1.parent_id) left join t_package as package_p3 on (package_p3.package_id = package_p2.parent_id)
where  c.object_type in ('Class','Interface')
and c.name like '<Search Term>'
and c.stereotype not like 'table'
and (
    (package.package_id in (#Branch# ) or package.package_id = #Package#)
or (package_p1.package_id in (#Branch# ) or package_p1.package_id = #Package#)
or (package_p2.package_id in (#Branch# ) or package_p3.package_id = #Package#)
or (package_p3.package_id in (#Branch# ) or package_p3.package_id = #Package#)
Geert
Title: Re: Usage of the Macro #Branch#
Post by: Hartmut Jung on June 22, 2011, 04:40:02 pm
Thanks a lot. The example is working and it is exactly what we are looking for.

The strange thing is, this was the initial thought, but it did not work.

With best regards to all.

Hartmut Jung
Title: Re: Usage of the Macro #Branch#
Post by: Geert Bellekens on June 22, 2011, 05:03:42 pm
Hartmut,

I had some trouble at first when I tried this as well.
Turned out that EA is case sensitive with regards to these macros, so #branch# doesn't work.

Geert
Title: Re: Usage of the Macro #Branch#
Post by: Hartmut Jung on June 23, 2011, 03:58:19 pm
Actually there are some strange things around the SQL-Queries going on.
There seems to be difference between a SQL-Query and a SQL-Query within the Search Builder. Only the Search Builder seems to expand the Macros #Branch#, #Package# or #DB#. In the SQL Query this is simply a syntax error.

Furthermore there are strange relation regarding the UPPERCASE notation of SQL keywords.
For example:
The statement A: select c.ea_guid AS CLASSGUID, c.object_type AS CLASSTYPE, c.name AS Name from
t_object c
where  
c.name rlike '<Search Term>'
and (
   (c.package_id in (#Branch# ) or c.package_id = #Package#)
)

and the statement B: select c.ea_guid as CLASSGUID, c.object_type as CLASSTYPE, c.name as Name from
t_object c
where  
c.name rlike '<Search Term>'
and (
   (c.package_id in (#Branch# ) or c.package_id = #Package#)
)

are syntactically equal. And both statements can be successfully executed as a Search in Search Builder. But one of the statements can NOT be seen in the selection of a search with in the Model Views Properties of a Search Folder. The statement with the LOWERCASE "as" are there invisible and therefore unselectable. Very tricky to find and understandable. But there it is.

Now it is working just fine.

With best regards

Hartmut Jung