Book a Demo

Author Topic: SQL query help  (Read 2842 times)

motivatedgorilla

  • EA User
  • **
  • Posts: 44
  • Karma: +0/-0
    • View Profile
SQL query help
« on: July 20, 2014, 11:41:53 pm »
I'm trying to return results similar to the package browser however via SQL however don't quite know how i can display the relationships. My code thus far.  Is there a way for me to do this? I'm running the query against an EAP file.

Code: [Select]
SELECT o.*,p.*
FROM   t_object AS o
INNER JOIN  t_package AS p on o.Package_ID = p.Package_ID
WHERE o.pdata1 IN (
    SELECT o2.pdata1
    FROM t_object AS o2
    )
ORDER BY p.parent_ID ASC


OpenIT Solutions

  • EA User
  • **
  • Posts: 555
  • Karma: +9/-1
    • View Profile
Re: SQL query help
« Reply #1 on: July 22, 2014, 10:05:03 pm »
Hi,

The first part of your query will return you all the elements in a package (plus the packages details). The second part of your query (WHERE opdata.... will not work).

If you want the details of each element in the currently selected package and its child packages add

WHERE p.package_id IN (#Branch#)

or for just the current package

WHERE p.package_id IN (#Package#)

If you want your users to be able to select rows in the result set and view the elements details or find it on diagram add...

SELECT o.ea_guid AS CLASSGUID, o.object_type AS CLASSTYPE ....


Regards,

Jon.