Book a Demo

Author Topic: SQL query for document generation.  (Read 3682 times)

Kaidou_91

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
SQL query for document generation.
« on: January 10, 2019, 08:18:59 pm »
Hi,

how can I use a SQL query to select some information from the element that is being processed by the template?
For example, I'm using this SQL query:

"   SELECT distinct t_operation.Type as ReturnType, t_operation.Name as OperationName, t_operation.Scope as OperationScope, t_operationparams.Type as ParamType, t_operationparams.Name as ParamName, t_operationparams.Kind as ParamDirection, t_operation.Object_ID as ObjID
FROM  t_operation, t_operationparams
where t_operation.OperationID = t_operationparams.OperationID and t_operation.Object_ID = #CurrentElementID#    "

                                                                                                                                                                                                                                                                                                                                                                              with the macro "#CurrentElementID#" for selecting the information needed from the current element. Does it look right?
I tried the above query (replacing #CurrentElementID# with an actual ElementID) in the search panel and it works.

Could someone please explain me how it works?

Thanks

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13521
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: SQL query for document generation.
« Reply #1 on: January 10, 2019, 08:24:25 pm »
Please read https://www.sparxsystems.com/enterprise_architect_user_guide/14.0/model_publishing/custom_sql_fragments.html

There is no such thing as #CurrentElementID#, but you can use #OBJECTID#

Geert

PS. I would use the join syntax to join tables.

Kaidou_91

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: SQL query for document generation.
« Reply #2 on: January 10, 2019, 08:40:43 pm »
I found "#CurrentElementID#" macro in here : https://www.sparxsystems.com/enterprise_architect_user_guide/14.0/model_navigation/creating_filters.html
But probably I didn't use it right  ;D

Anyway #OBJECTID# worked.

Thanks!