Book a Demo

Author Topic: Custom SQL and Current tree selection  (Read 5278 times)

peuhhhh

  • EA User
  • **
  • Posts: 31
  • Karma: +0/-0
    • View Profile
Custom SQL and Current tree selection
« on: April 22, 2010, 12:23:55 am »
Hello,
I'd like to know if it is possible and how to create a custom sql search in order to run it on the current tree selection ?

Thanks

Peuhhhh
« Last Edit: April 22, 2010, 12:26:16 am by peuhhhh »

Graham_Moir

  • EA User
  • **
  • Posts: 749
  • Karma: +10/-15
    • View Profile
Re: Custom SQL and Current tree selection
« Reply #1 on: April 22, 2010, 12:46:11 am »
You can certainly do custom SQL searches,  however they're across the whole model I believe.

In version 8,  look at the "Model Search" option on the Edit menu, then take the "Manage searches.."  option and choose "New search" from the toolbar.  When the panel comes up you'll see a SQL Editor option

Have a look at "create search definitions" in the Help for more information.  

peuhhhh

  • EA User
  • **
  • Posts: 31
  • Karma: +0/-0
    • View Profile
Re: Custom SQL and Current tree selection
« Reply #2 on: April 22, 2010, 12:49:21 am »
Thanks for your answer,

first of all and unfortunatly i work on the 7.5. In fact i know how to create Custom Sql Search but my problem is to specify it to run on the current tree selection and not on the whole model.

if you have an idea ?

peuhhhh

  • EA User
  • **
  • Posts: 31
  • Karma: +0/-0
    • View Profile
Re: Custom SQL and Current tree selection
« Reply #3 on: April 22, 2010, 01:17:34 am »
I tried to run some recursive SQL into the SQL editor ("With" Key). The Goal is to use the search term as my search root ( my current tree selection in other words).

But it shows like it dont works, but i dont have any messages

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Custom SQL and Current tree selection
« Reply #4 on: April 22, 2010, 01:30:32 am »
recursive queries don't work, and I don't think you can use the currently selected element in an SQL search.
You probably can in an addin-search, if I understood correctly that allows you to write some code to perform the search.
The addin code has access to the currently selected element (both in the projectbrowser as on diagrams)

Geert

peuhhhh

  • EA User
  • **
  • Posts: 31
  • Karma: +0/-0
    • View Profile
Re: Custom SQL and Current tree selection
« Reply #5 on: April 22, 2010, 08:04:01 pm »
Thanks guys,
in fact my need is to know the Node Path for Any object of a given type.
As instance if i want all the GUIElement i'd like to know the full Node PAth.

And i cant find the way to do this.

Any Idea?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Custom SQL and Current tree selection
« Reply #6 on: April 22, 2010, 11:36:40 pm »
Right click/ copy reference/Copy node path to Clipboard

Is that what you are looking for?

Geert

peuhhhh

  • EA User
  • **
  • Posts: 31
  • Karma: +0/-0
    • View Profile
Re: Custom SQL and Current tree selection
« Reply #7 on: April 22, 2010, 11:39:02 pm »
i want the same result but for all object in a given package using the search engine

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Custom SQL and Current tree selection
« Reply #8 on: April 22, 2010, 11:43:52 pm »
I have this in my code to export the package contents to an excel file
On of the fields is the qualified name.
Since recursive queries don't work I have joined t_package 10 times. You might need to extend that depending on the nesting depth you have.
Code: [Select]
" SELECT o.Object_ID as ID,o.Object_Type as Type,isNull(o.Name,'') as Name,ISNULL(t.value,0) as ImportanceLevel,isnull(o.Author,'') as Author,o.CreatedDate as Created,o.ModifiedDate as Modified,isnull(o.Note,'') as Documentation,isnull(o.Package_ID,'') as ParentID,isnull(p.name,'') as ParentName  " +
                " ,isnull(p9.Name +'.','') + isnull(p8.Name+'.','')+ isnull(p7.Name+'.','')+ isnull(p6.Name+'.','') " +
                " + isnull(p5.Name+'.','')+ isnull(p4.Name+'.','')+ isnull(p3.Name+'.','')+ isnull(p2.Name+'.','')+ isnull(p.Name,'') as QualifiedName " +
                " FROM t_object as o  " +
                " left join t_objectproperties t on t.Object_ID = o.Object_ID " +
                " left join t_package p on o.Package_ID = p.Package_ID " +
                " left join t_package p2 on p.Parent_ID = p2.Package_ID " +
                " left join t_package p3 on p2.Parent_ID = p3.Package_ID " +
                " left join t_package p4 on p3.Parent_ID = p4.Package_ID " +
                " left join t_package p5 on p4.Parent_ID = p5.Package_ID " +
                " left join t_package p6 on p5.Parent_ID = p6.Package_ID " +
                " left join t_package p7 on p6.Parent_ID = p7.Package_ID " +
                " left join t_package p8 on p7.Parent_ID = p8.Package_ID " +
                " left join t_package p9 on p8.Parent_ID = p9.Package_ID " +

                " where (t.Property = 'ImportanceLevel' or t.Property is null)" +
                " and o.ModifiedDate > '" + sqlDateModified + "' " +
                " and (p.package_ID = " + this.getPackageID() + "  " +
                    " or p2.package_ID = " + this.getPackageID() + "  " +
                    " or p3.package_ID = " + this.getPackageID() + "  " +
                    " or p4.package_ID = " + this.getPackageID() + "  " +
                    " or p5.package_ID = " + this.getPackageID() + "  " +
                    " or p6.package_ID = " + this.getPackageID() + "  " +
                    " or p7.package_ID = " + this.getPackageID() + "  " +
                    " or p8.package_ID = " + this.getPackageID() + "  " +
                    " or p9.package_ID = " + this.getPackageID() + " ) " +
                " order by QualifiedName";

Geert

peuhhhh

  • EA User
  • **
  • Posts: 31
  • Karma: +0/-0
    • View Profile
Re: Custom SQL and Current tree selection
« Reply #9 on: April 22, 2010, 11:48:57 pm »
Will help a lot thanks a lot Geert