Book a Demo

Author Topic: SQL search scope  (Read 10622 times)

Abett

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
SQL search scope
« on: August 24, 2018, 08:35:33 pm »
Hi there,

I'm looking to have an SQL query that will search everything held within a package and its branches whilst excluding one specific sub package of the original package and its branches. Currently I'm using (#Branch#) to define the package to exclude, but I've been unable to define the primary scope package. How would I be able to set the scope of the query to be able to do this?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: SQL search scope
« Reply #1 on: August 24, 2018, 09:18:35 pm »
You can't. Instead you either jump into writing a custom query (which is complicated up to impossible for recursions) or you script that appropriately.

q.

Abett

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: SQL search scope
« Reply #2 on: August 24, 2018, 09:33:03 pm »
I'm relatively inexperienced with scripting (I've dabbled in VB), how would be the best way to go about this?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: SQL search scope
« Reply #3 on: August 24, 2018, 10:03:15 pm »
EA has a build-in VB (not sure about the dialect) and there are a couple of example scripts (and of course there's my own Scripting book). EARepository has an operation to return a query result. You can find elements of a package by using the packageId as part of the Where-clause. You can traverse the packages by using the EAPackage.Packages thereby locating and omitting those you want to skip. Once you have all packages you can retrieve the elements therein (EAPackage.Elements).

q.

Helmut Ortmann

  • EA User
  • **
  • Posts: 970
  • Karma: +42/-1
    • View Profile
Re: SQL search scope
« Reply #4 on: August 26, 2018, 10:44:48 pm »
Hi,

There are a lot of good ways to query something, by SQL, by Add-In or by Script. Each way comes with its pros and cons.

If I need some non-trivial information out of EA, I usually use LINQPad. LINQPad is an interactive playground for the .net languages. You can easily combine code with SQL or even Linq for SQL the independent database approach.

You need some time to get familiar with it, but after that time you'll love it and use it for the more complex questions. After you have understood the solution, you may code it with Script or Add-In for a better EA integration.

By the way, with LINQPad you can quickly try a piece of code without bothering a lot about the environment.

Best regards,

Helmut
Coaching, Training, Workshop (Addins: hoTools, Search&Replace, LineStyle)

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: SQL search scope
« Reply #5 on: August 27, 2018, 05:01:59 pm »
You can also write search scripts that can be used in the search tool.

Here are some example scripts that are used directly in the search tool:
https://github.com/GeertBellekens/Enterprise-Architect-VBScript-Library/tree/master/Projects/Project%20A/Search%20Group

They include a lot of other scripts, but the main thing used is the SearchResults class: https://github.com/GeertBellekens/Enterprise-Architect-VBScript-Library/blob/master/Framework/Wrappers/Scripting/SearchResults.vbs

Geert