Author Topic: Element filter with SQL fragment?  (Read 1985 times)

Hurra

  • EA User
  • **
  • Posts: 153
  • Karma: +0/-0
    • View Profile
    • Find me at LinkedIn!
Element filter with SQL fragment?
« on: October 13, 2021, 12:26:35 am »
Hello!

I have a template with

PACKAGE>
DIAGRAM>


then I have an SQL fragment which finds the diagram objects and order after a tagged value, I have the SQL fragment because of my custom sorting criteria. (Can I do this another way?)

I would also like to add an element filter, for instance if I only want to include a specific element version. I tried

Element filters, on model document
Element filters, on SQL fragment

with no success.

I thought before I try other options on model document, template and SQL fragment, I would ask here.

Or is the only option to actually modify the SQL query to do the filtering of element version? But then I guess I need multiple, practically identical SQL fragments, with the different only being

WHERE element.Version = XXX

in the SQL query.


Thank you for your help!
always learning!

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 11314
  • Karma: +422/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Element filter with SQL fragment?
« Reply #1 on: October 13, 2021, 12:41:20 am »
Yes, your SQL fragment doesn't know about the data you are returning in your query, so it can' filter that based on some criteria in the template definition.

If you want to keep the fragment a bit more generic, you could use the version of the package or diagram instead of hardcoding it in the query.

Geert

PS. Not that you cannot use the diagram ID in your query. If you have multiple diagrams in your package you will have issues with this approach

Hurra

  • EA User
  • **
  • Posts: 153
  • Karma: +0/-0
    • View Profile
    • Find me at LinkedIn!
Re: Element filter with SQL fragment?
« Reply #2 on: October 13, 2021, 01:08:59 am »
Yes, your SQL fragment doesn't know about the data you are returning in your query, so it can' filter that based on some criteria in the template definition.

If you want to keep the fragment a bit more generic, you could use the version of the package or diagram instead of hardcoding it in the query.

Geert

PS. Not that you cannot use the diagram ID in your query. If you have multiple diagrams in your package you will have issues with this approach

Thank you Geert!

I will keep this approach in mind.

Regarding your PS, as for know I will use my whip to make sure there is only one diagram in the packages these reports will be used on :D
always learning!