Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Gusztav on March 09, 2015, 04:29:27 am

Title: Looking for parent of parent
Post by: Gusztav on March 09, 2015, 04:29:27 am
Hi. I have a bunch of activities organized into a hierarchy. For each activity, an activity diagram is specified with partitions and sub-activities, so the hierarchy looks like this:

Activity 1
  + Partition 1
      Subactivity 1 by Partition 1
      Subactivity 2 by Partition 1
  + Partition 2
      Subactivity 1 by Partition 2
      Subactivity 2 by Partition 2


I'm trying to develop a SQL search finding subactivities for activities, that is, those items being second-level children, to keep it simple.

I thought the following would work, but it does not:

select
    subActivity.ea_guid as CLASSGUID,
    subActivity.Name as [Task],      
    subActivity.Object_type as [Type]
    
from
    (  (
        t_object as activity
        inner join t_object as partition
            on partition.parent_ID = activity.Object_ID
       )
        inner join t_object as subActivity
            on subActivity.Parent_ID = partition.Parent_ID
    )                      
                                
where                                  
    activity.Object_Type in ('Activity', 'Action')
    and
    activity.Name like '#WC#<Search Term>#WC#'    
                                                  
order by activity.Name, subActivity.Name


When running the query, I receive a DAO 3061 errors, saying "Too few parameters. Expected 2". Trying to run the query in a 3rd party tool on the EAP file yields in error "Parameter partition.parent_id has no default value".

I have also tried the following variant of the query:

select
      subActivity.ea_guid as CLASSGUID,
      subActivity.Name as [Task],
      subActivity.Object_type as [Type]
      
from
      t_object as activity,
      t_object as partition,
      t_object as subActivity

where
      partition.Parent_ID = activity.Object_ID
      and
      subActivity.Parent_ID = partition.Object_ID
      and
    activity.Object_Type in ('Activity', 'Action')
      and
    activity.Name like '#WC#<Search Term>#WC#'

order by activity.Name, subActivity.Name


The results are the very same.

Could you, please, tell me what am I doing wrong? I know error 3061 usually refers to names what JET can not resolve, but I could not find such a typo in the code. And why lack of a default value would prevent me from checking the equivalence of such a field?

Gus
Title: Re: Looking for parent of parent
Post by: qwerty on March 09, 2015, 06:47:29 am
ParentID instead if Parent_ID will likely solve the issue.

q.
Title: Re: Looking for parent of parent
Post by: Geert Bellekens on March 09, 2015, 06:24:35 pm
A good idea to avoid these kind of issues is to use an external SQL editor to create your SQL queries.

I use a free "universal" tool called  AnySQL Maestro (http://www.sqlmaestro.com/products/anysql/maestro/) but there are many similar tools like that.

The "intellisense" feature of those type of editors usually helps to avoid typos.

Geert
Title: Re: Looking for parent of parent
Post by: qwerty on March 09, 2015, 08:28:10 pm
EA has also some of that "intellisense" but it's not that smart. It only works after you write the table name and the dot, not for an alias.

q.