Book a Demo

Author Topic: Absolute Novice at SQL  (Read 3364 times)

EmyrI

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Absolute Novice at SQL
« on: July 13, 2018, 10:05:12 pm »
hi folks, as well as being very new to EA as a software package and as career i am trying to learn as best i can. I am having some difficulty with learning SQL side of search the model

My initial SQL bore some fruit which was the very simplistic following:
Code: [Select]
SELECT ea_guid AS CLASSGUID, Object_Type AS CLASSTYPE, Name FROM t_object

where Name like '*Benefit*' or Name='*Benefit*'

I wanted to add some information to the search so that i can figure out where in my model this is found, borrowing from Geert's sql searches i devised the following to get some extra columns, where i am looking to get packnames and stereotypes listed

Code: [Select]
SELECT ea_guid AS CLASSGUID, Object_Type AS CLASSTYPE, Name as Name
,package.name as 'Package Name' ,package_p1.name as 'Package level -1',package_p2.name as 'Package level -2',package_p3.name as 'Package level -3'

from (((( t_object
inner join t_package package on package_id = package.package_id)
left join t_package package_p1 on package_p1.package_id = package.parent_id)
left join t_package package_p2 on package_p2.package_id = package_p1.parent_id)
left join t_package package_p3 on package_p3.package_id = package_p2.parent_id)

where Name like '*Benefit*' or Name like '*Benefit*'

Sadly i cannot make this work and i have no idea why it wont work, can anyone point me in the right direction?
« Last Edit: July 13, 2018, 10:13:45 pm by EmyrI »

Arshad

  • EA User
  • **
  • Posts: 291
  • Karma: +21/-1
    • View Profile
Re: Absolute Novice at SQL
« Reply #1 on: July 13, 2018, 11:11:04 pm »
Hi EmyrI

Try this query

Code: [Select]
SELECT  t_object.Name ,package.Name as 'Package Name' ,package_p1.Name as 'Package level -1',package_p2.Name as 'Package level -2',package_p3.Name as 'Package level -3'
from (((( t_object
inner join t_package package on t_object.Package_ID = package.Package_ID)
left join t_package package_p1 on package_p1.Package_ID = package.Package_ID)
left join t_package package_p2 on package_p2.Package_ID = package_p1.Package_ID)
left join t_package package_p3 on package_p3.Package_ID = package_p2.Package_ID)
where t_object.Name like '*Benefit*' or t_object.Name like '*Benefit*'

Problem is due to case sensitive and some name mismatch. (eg) For Package_ID you have mentioned as package_id. just modified that in your query .


HTH
Arshad
« Last Edit: July 13, 2018, 11:12:43 pm by Arshad »

EmyrI

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: Absolute Novice at SQL
« Reply #2 on: July 14, 2018, 12:05:07 am »
thank you arshad, much appreicated

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Absolute Novice at SQL
« Reply #3 on: July 14, 2018, 12:08:08 am »
Look into %appdata%.../Sparx/...dberror.txt which eventually contains more details SQL error messages. Unfortunately you don't tell us what the issue is except "does not work".

q.