Author Topic: Custom Documentation - SQL query  (Read 852 times)

balajib

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Custom Documentation - SQL query
« on: June 11, 2025, 09:51:37 pm »
Hi team,

Below is the code used to bring the level 1 components, wanted to bring the level 2 components also which is connected as a child diagram to any one of the level1 component, Need support to modify this code.
select
t_object.Name as Name
FROM t_object
INNER JOIN t_connector ON t_object.Object_ID = t_connector.Start_Object_ID
WHERE t_connector.connector_Type = 'Aggregation'
AND t_connector.End_Object_ID = 1097
 

Daiim

  • EA User
  • **
  • Posts: 51
  • Karma: +0/-0
    • View Profile
Re: Custom Documentation - SQL query
« Reply #1 on: June 12, 2025, 10:01:19 pm »
Can you be a bit more precise please?

Code: [Select]
SELECT
    source.Name as 'Some Name'
FROM t_object source
    LEFT JOIN t_connector link1 ON (link1.Start_Object_ID = source.Object_ID AND link1.Connector_Type = 'Aggregation')
   LEFT JOIN t_object target ON (link1.End_Object_ID = target.Object_ID)
WHERE
   target.Object_ID = 1097

You can go on with additional LEFT JOINS to query for a path. You should not rely on the Object_ID as this is not your model element identity but a database related key that may and will change!

balajib

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Custom Documentation - SQL query
« Reply #2 on: June 13, 2025, 03:16:05 pm »
Thank you, I have learnt two things 1) that not to use numeric IDs and instead to use #ObjectID# to call any model element 2) define the table names like t_connector as link and use it as required.

My previous msg is
In Level1-  The code brings level 1 architecture (BDD) elements as Element1, Element 2, Element3... having aggregation relation.
In Level 2 - There is another BDD,s  available inside any one or two or more of the level 1 BDD elements (say Element1,Element2,Element3...) in aggregation relation.

In level the start object element becomes the end object if it contains any BDD in as child diagarm,How to bring those elements also.

SELECT source.Name AS ComponentName
FROM t_object AS source
LEFT JOIN t_connector AS link1
    ON link1.Start_Object_ID = source.Object_ID
    AND link1.Connector_Type = 'Aggregation'
LEFT JOIN t_object AS target
    ON link1.End_Object_ID = target.Object_ID
WHERE target.Object_ID = #OBJECTID#

Output:
Element1
Element2
Element3


Daiim

  • EA User
  • **
  • Posts: 51
  • Karma: +0/-0
    • View Profile
Re: Custom Documentation - SQL query
« Reply #3 on: June 13, 2025, 04:58:50 pm »
For recursion and graph pattern matching use the custom script variant (jscrip, vbscript or javascript) instead of sql queries. For documentation see: https://sparxsystems.com/enterprise_architect_user_guide/17.1/model_publishing/custom_script_fragments.html (here is an example of the expected return format: https://sparxsystems.com/enterprise_architect_user_guide/17.1/model_publishing/example_output_of_an_rtf_templ.html). You can use the xml node names inside the <Row></Row> node via "insert custom fields" inside your template. For multiple results, repeat the <Row></Row> node.