Book a Demo

Author Topic: Trouble with writing a SQL template fragment  (Read 5034 times)

John Arnold

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Trouble with writing a SQL template fragment
« on: December 02, 2014, 10:53:53 pm »
Hi folks I'm trying to write a template fragment based on a SQL query.

My query (very basic at the moment) is

select Object_Name as PortName from t_object where Object_Type = "Node" and Package_ID = #PACKAGEID#

But I'm getting the error message

DAO.Database [3061]
Too few parameters.  Expected 1.


any ideas?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Trouble with writing a SQL template fragment
« Reply #1 on: December 02, 2014, 11:03:33 pm »
try
Code: [Select]
select o.Name as PortName from t_object o
where o.Object_Type = 'Node'
and o.Package_ID = #PACKAGEID#

Geert

John Arnold

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Trouble with writing a SQL template fragment
« Reply #2 on: December 02, 2014, 11:16:03 pm »
Many thanks for the suggestion Geert, but I still get the same error.
John

Quote
try
Code: [Select]
select o.Name as PortName from t_object o
where o.Object_Type = 'Node'
and o.Package_ID = #PACKAGEID#

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Trouble with writing a SQL template fragment
« Reply #3 on: December 03, 2014, 12:23:16 am »
Your first query used Object_Name which does not exist. Hence the too few parameters. Geert's SQL is correct. So what kind of error do you get?

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Trouble with writing a SQL template fragment
« Reply #4 on: December 03, 2014, 12:38:00 am »
Quote
Many thanks for the suggestion Geert, but I still get the same error.
John

Quote
try
Code: [Select]
select o.Name as PortName from t_object o
where o.Object_Type = 'Node'
and o.Package_ID = #PACKAGEID#

Geert

You also had the #Package# macro wrong. This actually works.

Code: [Select]
select o.Name as PortName from t_object o
where o.Object_Type = 'Node'
and o.Package_ID = #Package#

You do know that you can't just make up anything when writing SQL don't you?
Columns and macros actually have to exists in order to use them.

Geert

John Arnold

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Trouble with writing a SQL template fragment
« Reply #5 on: December 03, 2014, 12:58:21 am »
Geer, I have been researching this a bit but I still can't make it work.

the #package# macro is used in searches, but #packageid# is used in template fragments.

I do know I can't write just anything, but I can't find a proper description of the object model Sparx is using so it's difficult to know what the correct fields are.

You also had the #Package# macro wrong. This actually works.

Code: [Select]
select o.Name as PortName from t_object o
where o.Object_Type = 'Node'
and o.Package_ID = #Package#

You do know that you can't just make up anything when writing SQL don't you?
Columns and macros actually have to exists in order to use them.

Geert
[/quote]

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Trouble with writing a SQL template fragment
« Reply #6 on: December 03, 2014, 01:22:44 am »
Quote
I do know I can't write just anything, but I can't find a proper description of the object model Sparx is using so it's difficult to know what the correct fields are.

You can either open your .eap file with ms-access (or another generic sql client) or reverse engineer the .eap file (or dmbs repository) into EA.

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Trouble with writing a SQL template fragment
« Reply #7 on: December 03, 2014, 05:22:03 am »
Or you can refer to my Inside book.

q.