Book a Demo

Author Topic: Looking for parent of parent  (Read 3644 times)

Gusztav

  • EA User
  • **
  • Posts: 32
  • Karma: +0/-0
  • EA expert
    • View Profile
    • Imprestige. Your issues in safe hands.
Looking for parent of parent
« 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
« Last Edit: March 09, 2015, 04:31:08 am by imprestige »
------------------------
Imprestige. Your issues in safe hands.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Looking for parent of parent
« Reply #1 on: March 09, 2015, 06:47:29 am »
ParentID instead if Parent_ID will likely solve the issue.

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13471
  • Karma: +571/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Looking for parent of parent
« Reply #2 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 but there are many similar tools like that.

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

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Looking for parent of parent
« Reply #3 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.