Book a Demo

Author Topic: How to debug a template fragment with Custom SQL [solved with workaround]  (Read 6214 times)

Shegit Brahm

  • EA User
  • **
  • Posts: 98
  • Karma: +1/-0
    • View Profile
Hi there,

I'm writing template fragments and need to play around with the SQL queries as I'm not that familiar with it.

Now it happens that I get more or less useful error messages from EA and I wonder: which way could I use to debug a template fragment?

I tried to create a search first and use it. It seems that it's not always possible - should it be?
(like usage both of #PACKAGEID# and #OBJECTID# inside a query)

Even if I don't get an error, the fragment does nothing because my query didn't deliver anything - so I need to evaluate why.

Thanks,
Shegit
« Last Edit: January 19, 2018, 08:56:37 pm by Shegit Brahm »

Nabil

  • EA User
  • **
  • Posts: 149
  • Karma: +5/-2
    • View Profile
    • View My LinkedIn Profile Here
Re: How to debug a template fragment with Custom SQL
« Reply #1 on: January 19, 2018, 02:14:22 am »
To debug your query use sql builder crtl+f. Yes only packageId, diagramId and objectId are the possible arguments
« Last Edit: January 19, 2018, 03:54:55 am by Nabil »
Nabil

Nizam

  • Prolab Moderator
  • EA User
  • *
  • Posts: 320
  • Karma: +15/-2
  • Model Sharing - Simplified
    • View Profile
    • Professional Model Collaboration
Re: How to debug a template fragment with Custom SQL
« Reply #2 on: January 19, 2018, 08:16:16 pm »
Hi there,

I'm writing template fragments and need to play around with the SQL queries as I'm not that familiar with it.

Now it happens that I get more or less useful error messages from EA and I wonder: which way could I use to debug a template fragment?

I tried to create a search first and use it. It seems that it's not always possible - should it be?
(like usage both of #PACKAGEID# and #OBJECTID# inside a query)

Even if I don't get an error, the fragment does nothing because my query didn't deliver anything - so I need to evaluate why.

Thanks,
Shegit

I'd suggest you find the ObjectID of the element you are trying to report and replace #OBJECTID# with that and see if you are fetching the right results.

Secondly, just make sure the right fragment is called at the right time, by printing some static text in the fragment



Shegit Brahm

  • EA User
  • **
  • Posts: 98
  • Karma: +1/-0
    • View Profile
As far as I understand is ctrl+f the project wide search where I could test the select step by step as it "grows".

Well, did that already.

And I also add some text outside the custom> <custom tags to see if I entered the fragment (everything inside these angle brackets gets printed only if the fragment query itself returned something.

I understand that I need simple fragments that return only #objectid# etc. to use that knowledge and replace #OBJECTID# inside search with hard numbers.
=> Instead " ob1.object_id = #OBJECTID#" I transform it for the search into " ob1.object_id = 524 "

Because my fragments usually start on a package that contains only a diagram and no elements - so I'm unable to start the search on the package or the diagram as there is no "CurrentElementID" if there is no element the search starts on  (http://sparxsystems.com/enterprise_architect_user_guide/13.0/model_navigation/creating_filters.html)

Unless someone knows any other options, I mark it as solved with workaround.

Thanks,
Shegit

Nizam

  • Prolab Moderator
  • EA User
  • *
  • Posts: 320
  • Karma: +15/-2
  • Model Sharing - Simplified
    • View Profile
    • Professional Model Collaboration
Because my fragments usually start on a package that contains only a diagram and no elements - so I'm unable to start the search on the package or the diagram as there is no "CurrentElementID" if there is no element the search starts on  (http://sparxsystems.com/enterprise_architect_user_guide/13.0/model_navigation/creating_filters.html)

Your <element> tag within the <diagram> tag also calls the template you've defined for <element> under package, if you leave the Diagram -> Element blank
So your template fragments will be called.

sharing your template and fragment could help