Sparx Systems Forum

Enterprise Architect => General Board => Topic started by: Tony D on January 20, 2016, 12:25:27 pm

Title: Execute SQL Stored Procedure
Post by: Tony D on January 20, 2016, 12:25:27 pm
I have a complex query which creates a dynamic pivot table to retrieve a matrix (similar to relationship matrix).  I have created this as a stored procedure in the DB, with an input parameter of Package Name. 

Can I execute a stored procedure from the SQL query/search?  I would then want to extend this to a Template fragment if possible, to include the results in a document. 


My ultimate objective is to provide a document per Package, with a cutdown matrix of Use Cases to realising Components that is relevant to the Package.  Note the Components and Use Cases live in separate Packages, so I have included them on a specific diagram within the Package to determine which UCs/Components are relevant for export.
Title: Re: Execute SQL Stored Procedure
Post by: Geert Bellekens on January 20, 2016, 02:35:38 pm
Tony,

Have you tried?
I know EA requires the query to start with "SELECT", but other then that I don't expect too much limitations.

But I'm not so sure if a stored procedure is really a good idea. In general I avoid changing the database structure in any way because otherwise I have to carry those modifications with me everywhere I (or the model) go.
Things like model transfer are suddenly not enough to move a model to another database,

Using the package Name as parameter might also not be the best idea. What if more then one package with the same name exist?
Seems like you should use the PackageID or the ea_guid as parameter instead.

Are you aware you can use the macros #Package# and #Branch# to get a hold of the currently selected package? See http://sparxsystems.com/enterprise_architect_user_guide/12.1/building_models/creating_filters.html (http://sparxsystems.com/enterprise_architect_user_guide/12.1/building_models/creating_filters.html) for more info

Geert
Title: Re: Execute SQL Stored Procedure
Post by: Tony D on January 20, 2016, 04:59:20 pm
Thanks Geert
I have tried, but haven't been successful as yet (am currently investigating execution from script).

Regarding the Package ID/Name - I was intending on using the Package (ID) macro.

I have since had some success filtering the Relationship Matrix to retrieve the desired results by adding some Tagged Values for the required Elements.  I've done this by filtering on the Tagged Value. 

However now I run into issues that I cant export a specific Relationship Matrix in a document. 

Anyone had much luck documenting Relationship Matrix?  What do you do when elements come from different Packages?
Title: Re: Execute SQL Stored Procedure
Post by: Geert Bellekens on January 20, 2016, 05:58:32 pm
I did experiment with relationship matrices in documents, but the output turned out to be an (ugly) image of the relationship matrix, which was not at all what I was after.
As an alternative we now use SQL fragments that return a table with the same information as would be in the matrix. The downside of that is that this approach is harder to interpret and more verbose then the matrix approach.

Come to think of it, a document script fragment might be a solution to this as you then have full control of the contents of the document part, and you can create tables with a variable number of columns. Hmm, requires some more investigation :)

Geert
Title: Re: Execute SQL Stored Procedure
Post by: Helmut Ortmann on January 21, 2016, 04:47:59 pm
Hi Tony,

you may create an Addin with an Add-In Search (see: http://sparxsystems.com/enterprise_architect_user_guide/12.1/automation_and_scripting/add-in_search.html).

Inside the Addin you can handle with all SQL aspects (also stored procedures) and return the result values as *.xml for EA to display in the SQL Search View.

Inside your Addin-Search you can get selected items like elements, packages, diagrams,.. to fit your needs.

Regards,

Helmut