Sparx Systems Forum

Enterprise Architect => Suggestions and Requests => Topic started by: PeterHeintz on June 27, 2016, 10:47:37 pm

Title: SQL Search macro #BranchGUIDorID= xyz#
Post by: PeterHeintz on June 27, 2016, 10:47:37 pm
Searching recursively children of a parent is not really simple in SQL. EA already provides the #Branch# macro which simplifies to find all children of a selected package.

However I have several use cases where this feature would be very useful if I could define the package without selecting it.

Example: a Kanban related to a higher level package could be updated by sql selecting elements under the higher level package.
Due to the fact that the feature is in principle already there, the implementation seems to me to be easy.
Title: Re: SQL Search macro #BranchGUIDorID= xyz#
Post by: Paolo F Cantoni on June 28, 2016, 09:59:31 am
+1

Paolo
Title: Re: SQL Search macro #BranchGUIDorID= xyz#
Post by: Helmut Ortmann on June 28, 2016, 02:55:48 pm
Hi,

If I understand you right:

Select a Diagram, Element,.. and use #Branch# in SQL than you get the comma seperated list of Package IDs which you can use in SQL.

If you have this in mind you can get help by using hoTools and the SQL features. It provides this.
See:
http://community.sparxsystems.com/community-resources/977-hotools-sql-with-tabbed-editing-macros-templates (http://community.sparxsystems.com/community-resources/977-hotools-sql-with-tabbed-editing-macros-templates) or
https://github.com/Helmut-Ortmann/EnterpriseArchitect_hoTools/wiki/hoTools (https://github.com/Helmut-Ortmann/EnterpriseArchitect_hoTools/wiki/hoTools)

I you have something else in mind please explain it.

Regards,

Helmut
Title: Re: SQL Search macro #BranchGUIDorID= xyz#
Post by: qwerty on June 28, 2016, 05:35:19 pm
No, he wants it explicitly, using a parameter rather than setting a manual focus.

q.
Title: Re: SQL Search macro #BranchGUIDorID= xyz#
Post by: PeterHeintz on June 28, 2016, 09:01:00 pm
Yes, I confirm I want an explicit parameter rather than selection something in the browser.
This would allow filtering things under a package without selection it.
Title: Re: SQL Search macro #BranchGUIDorID= xyz#
Post by: Paolo F Cantoni on June 29, 2016, 09:34:56 am
Yes, I confirm I want an explicit parameter rather than selection something in the browser.
This would allow filtering things under a package without selection it.
This is important for us because we have a standard repository structure where the same package in various snapshots and sub-set repositories has the same GUID.  These are hard-wired into our SQL queries and it would be good to be able to do the same in our searches.

Paolo
Title: Re: SQL Search macro #BranchGUIDorID= xyz#
Post by: Helmut Ortmann on June 29, 2016, 02:45:42 pm
Hi,

thanks, I got the picture.

If you need such a feature in hoTools as a SQL macro just drop me a line. It's no big deal and it's a simple extension of the existing #Branch# macro / concept.

Regards,

Helmut
Title: Re: SQL Search macro #BranchGUIDorID= xyz#
Post by: PeterHeintz on June 29, 2016, 04:23:42 pm
Helmut,
where I get this hoTools from?
Is it open source?
Title: Re: SQL Search macro #BranchGUIDorID= xyz#
Post by: qwerty on June 29, 2016, 06:58:19 pm
ho = Helmut Ortmann :-) It's his origin and he made it open source on github.

q.
Title: Re: SQL Search macro #BranchGUIDorID= xyz#
Post by: Helmut Ortmann on July 05, 2016, 03:16:10 pm
Hi PeterHeintz,

where pkg.package_ID in (#Branch={0E702249-BFFA-43cd-86C9-41D3324A7617}#) is now part of hoTools.

There is also a Context Menu to insert this with the current selected package.

You find it at (2.03):
https://github.com/Helmut-Ortmann/EnterpriseArchitect_hoTools/releases (https://github.com/Helmut-Ortmann/EnterpriseArchitect_hoTools/releases)

Possible Macros / WiKi:
https://github.com/Helmut-Ortmann/EnterpriseArchitect_hoTools/wiki/EaSqlMacros (https://github.com/Helmut-Ortmann/EnterpriseArchitect_hoTools/wiki/EaSqlMacros)

Regards,

Helmut
Title: Re: SQL Search macro #BranchGUIDorID= xyz#
Post by: PeterHeintz on July 05, 2016, 04:50:12 pm
Hello Helmut,
that is super!
I will try it today.
Thank you!
Title: Re: SQL Search macro #BranchGUIDorID= xyz#
Post by: McMannus on July 13, 2016, 01:11:00 am
Hi all, cool thing! I didn't know about the macros yet.

However, the simple query
Code: [Select]
SELECT * FROM t_object WHERE Package_ID IN (#Branch={D2B412CB-E1C6-4d59-A6B2-ECF22F7C8418}#)
fails for me with the following DAO error
Code: [Select]
DAO.Database [3075]

Syntax error in date in query expression 'Package_ID IN (#Branch={D2B412CB-E1C6-4d59-A6B2-ECF22F7C8418}#)'.

Context:
SQL: SELECT * FROM t_object WHERE Package_ID IN (#Branch={D2B412CB-E1C6-4d59-A6B2-ECF22F7C8418}#)

The package exists for sure with this GUID and the macro is exactly how Helmut described it.
Any ideas?
Title: Re: SQL Search macro #BranchGUIDorID= xyz#
Post by: PeterHeintz on July 13, 2016, 01:36:11 am
Did you install the hoTools on you EA installation?
Title: Re: SQL Search macro #BranchGUIDorID= xyz#
Post by: McMannus on July 13, 2016, 01:39:34 am
Yeah, I have it installed, but I thought the macros are processed by EA as well? It seems to me as EA simply passes the query as is to the database and doesn't resolve the macro, because in Access ## indicates date literals.
Title: Re: SQL Search macro #BranchGUIDorID= xyz#
Post by: Helmut Ortmann on July 13, 2016, 03:41:41 am
Hi,

you have to install hoTools and you have to run the SQL from the hoTools Addin in the AddinWindow, Tab 'SQL'.

The Macros are converted before it is sent to EA and then by EA to the Database / Repository. As benefit: If you get SQL errors hoTools automatically reads the EA error file and outputs it together with the error message.

To install it you have to have the rights to install a Windows dll (local administrator).

Kind regards,

Helmut

Title: Re: SQL Search macro #BranchGUIDorID= xyz#
Post by: McMannus on July 13, 2016, 03:53:06 am
Thanks for the enlightenment, Helmut! I thought this is a hidden EA feature that I can use in my add-ins as well :-)
Title: Re: SQL Search macro #BranchGUIDorID= xyz#
Post by: Helmut Ortmann on July 13, 2016, 08:10:17 pm
Hi  McMannus,

hoTools is a Windows COM Object. If you need the feature to run advanced SQL from another Addin or even Script (vbScript, JavaScript, JScript) you should be able to use the functionality.

The interface would be:

There could be two features:

If you are interested let me know.

On GitHub you can get the newest release and the current documentation. I don't always update the EA Community.

Regards,

Helmut
Title: Re: SQL Search macro #BranchGUIDorID= xyz#
Post by: qwerty on July 13, 2016, 08:20:09 pm
Helmut, you could save yourself quite some work by just linking the community site to your github page :-)

q.
Title: Re: SQL Search macro #BranchGUIDorID= xyz#
Post by: PeterHeintz on August 17, 2016, 09:25:58 pm
Thanks to Helmut’s hoTools the functionality is available, however I think to have the feature build in EA would be good e.g. build “self-maintained” Kanbans having elements underneath a defined package. A more general implementation would be to have the possibility to call script methods from SQL returning a SQL fragment as string.