Author Topic: SQL Query Issue  (Read 1316 times)

lynch80516

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
SQL Query Issue
« on: February 29, 2020, 12:03:28 pm »
I have a query that I use to gather up attributes. The query is below.

select obj.Object_ID, obj.Name as Obj_Name, att.Name, att.Type, att. as 'Value'
, tv1.VALUE as Tag1, tv2.VALUE as Tag2
, att.Notes as Notes
From t_object obj, t_attribute att
left join t_attributetag tv1 on att.ID= tv1.ElementID
                     and tv1.Property = 'Unit of Measure'
left join t_attributetag tv2 on att.ID = tv2.ElementID
                     and tv2.Property = 'MsgColumn'
inner join t_object on  att.Object_ID = t_object.Object_ID   
where att.Object_ID = obj.Object_ID

This query works but searches the entire model, if I substitute #OBJECTID# for obj.Object_ID in the last line the query fails with Invalid Column #OBJECTID#

Has anyone seen this before and found a solution.

John

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 12254
  • Karma: +484/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: SQL Query Issue
« Reply #1 on: February 29, 2020, 05:18:07 pm »
John,

Where are you using this query? In a search or in a template.

Templates work with #OBJECTID#, but searches don't.
In SQL Searches you can use macro's such as #CurrentElementID#

Geert