Book a Demo

Author Topic: SQL query for connections with name="External Reference"  (Read 7059 times)

ngong

  • EA User
  • **
  • Posts: 275
  • Karma: +2/-2
    • View Profile
SQL query for connections with name="External Reference"
« on: June 21, 2018, 03:55:49 am »
Dear SQL specialist,
I would appreciate some help on creating a query. I am missing some very first steps.
I did SQL some decades ago, read some examples from Geert, scanned "enterprise-architect-object-model.pdf". I can do a query like

select c.Connector_ID as id, c.name from t_connector c where c.name="External Reference"

and get two columns. What I need is, for each row the name and type of ClientEnd and SupplierEnd.
A benefit would be the containing package name for each.
 
But if I add anything to my query I always get "Runtim error 3061. Too few parameters. Expected 1."
(e.g. the pdf says t_connector has a column Alias and ClientID, but c.Alias or c.ClientID leads to the error)

What did I miss?
Rolf

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 query for connections with name="External Reference"
« Reply #1 on: June 21, 2018, 01:41:02 pm »
Rolf,

I'd suggest you get a proper SQL tool to write your queries.
I'm using AnySQL Maestro when writing queries for an .eap model.

Such tools have intellisense and much better error handling than EA.
Only when my query works in that tool I will copy/past it in EA.

Geert

PS. EA also has some autocomplete feature  for column names, but that only works when you type in the full table table e.g. "t_connector"

Nizam

  • Prolab Moderator
  • EA User
  • *
  • Posts: 320
  • Karma: +15/-2
  • Model Sharing - Simplified
    • View Profile
    • Professional Model Collaboration
Re: SQL query for connections with name="External Reference"
« Reply #2 on: June 21, 2018, 03:06:05 pm »
Geerts suggestion is best to create useful queries, but Coincidentally i had something similar written for reporting purpose

Code: [Select]
select c.Name as Name, ce.Name as ClientName,  ce.Object_Type as ClientType, se.Name as SupplierName, se.Object_Type as SupplierType   
from (( t_connector c
left join t_object ce on ce.Object_ID = c.End_Object_ID )
left join t_object se on se.Object_ID = c.Start_Object_ID )
where c.Name ='<Name>'

ngong

  • EA User
  • **
  • Posts: 275
  • Karma: +2/-2
    • View Profile
Re: SQL query for connections with name="External Reference"
« Reply #3 on: June 21, 2018, 04:20:27 pm »
wonderful, Nizam - works out of the box. Now I learned e.g. that column Start_Object_ID is foreign key to t_object.

I will try to convince IT to install AnySQL Maestro on the company laptop I am using.

However: where to read further? Not so much SQL, but EA relational schema. Start_Object_ID does not appear in enterprise-architect-object-model.pdf. I am obviosly reading the wrong document. Which of the documents in www.sparxsystems.com.au/resources/user-guides holds that information?

However, I installed AnySQL on my private computer and it seems that I get all most needed information just from connecting to an .eap file. Thank you Geert.
Rolf

Nizam

  • Prolab Moderator
  • EA User
  • *
  • Posts: 320
  • Karma: +15/-2
  • Model Sharing - Simplified
    • View Profile
    • Professional Model Collaboration
Re: SQL query for connections with name="External Reference"
« Reply #4 on: June 21, 2018, 04:35:16 pm »
Glad it helped. You can refer to https://leanpub.com/InsideEA from Thomas Kilian

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 query for connections with name="External Reference"
« Reply #5 on: June 21, 2018, 05:36:39 pm »
The object model is the model for the API, not for the database.

You can simply reverse an .eap file in EA to get the database structure and/or get Thomas's book.

Geert

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: SQL query for connections with name="External Reference"
« Reply #6 on: June 22, 2018, 08:51:06 am »
And don't forget that you can use intellisense. Unfortunately, when typing a SQL statement like this into EA's SQL builder

select c.Connector_ID as id, c.name from t_connector c where c.name="External Reference"

you don't get intellisense when you type c. but if you type t_connector. then you will see all the fields available in that table.
The Sparx Team
[email protected]

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 query for connections with name="External Reference"
« Reply #7 on: June 22, 2018, 03:51:08 pm »
you don't get intellisense when you type c. but if you type t_connector. then you will see all the fields available in that table.

Would be nice if that could be fixed. Nobody uses full table names when writing queries.
I actually never write or edit a query directly in EA because of the missing intellisense on aliases.

Geert