Author Topic: Another error using SQL  (Read 13435 times)

Ian Mitchell

  • EA User
  • **
  • Posts: 506
  • Karma: +22/-4
  • The eaDocX and Model Expert guy
    • View Profile
Another error using SQL
« on: March 14, 2016, 10:24:25 pm »
Trying to use the the SQL:
" Select   T_OBJECT.name, Object_Type, Stereotype, COUNT(*) from T_OBJECT  "
 group by T_OBJECT.name, Object_Type, Stereotype "
HAVING COUNT(*) > 1"
(which finds duplicate elements in a model)
-
  • Works fine in the model search with EAP file
  • Works fine called via Repository.SQLQuery to EAP file
  • Works fine in a model search with mySQL
  • Doesn't work with Repository.SQLQuery in mySQL
..and the error is the one so often mentioned in this forum:
Error: Code = 0x0 Source Line: 0; Char : 0, Error Description = (null).

This is an especially nasty error because (a) it's very unhelpful and (b) keeps repeating until the use crashes EA.
Other forum items suggest changing the SQL a bit, but this really is what I need the query to look like. About the only change possible is to change the select(*) to a select(Name), but that doesn't work either.
Does anyone have an ideas either (a) how to get around this or (b) how to get more helpful error message from EA ?
Ian Mitchell, Designer, eaDocX


www.eaDocX.com
www.theartfulmodeller.com

Ian Mitchell

  • EA User
  • **
  • Posts: 506
  • Karma: +22/-4
  • The eaDocX and Model Expert guy
    • View Profile
Re: Another error using SQL
« Reply #1 on: March 14, 2016, 10:28:19 pm »
Update: Just tried using SQLServer, and that also works OK in a Search, but throws the same error when called via the Repository interface.
Ian Mitchell, Designer, eaDocX


www.eaDocX.com
www.theartfulmodeller.com

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13136
  • Karma: +547/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Another error using SQL
« Reply #2 on: March 14, 2016, 11:13:26 pm »
Ian,

What does dbError.txt contain?
Often that is more helpful then the error message in EA.

Geert


Helmut Ortmann

  • EA User
  • **
  • Posts: 967
  • Karma: +42/-1
    • View Profile
Re: Another error using SQL
« Reply #3 on: March 14, 2016, 11:21:45 pm »
Hi Ian,

have you looked into dberror.txt in %APPDATA%...

Next I would try to slightly change the SQL. I'm not sure if EA pre processes the SQL before launching it. Try e.g:
from t_object o  and all usages with o. (lower case)

I would also try to enter the query with another query tool (sqlServer Management platform is pretty good and free)

Ok, I admit a lot of try and error.

Kind regards,

Helmut
Coaching, Training, Workshop (Addins: hoTools, Search&Replace, LineStyle)

Ian Mitchell

  • EA User
  • **
  • Posts: 506
  • Karma: +22/-4
  • The eaDocX and Model Expert guy
    • View Profile
Re: Another error using SQL
« Reply #4 on: March 15, 2016, 03:29:25 am »
Honestly, I had no idea that DBError.txt existed. 12 wasted years using EA.
But anyway, it just contains an error from earlier today, just a simple SQL syntax error - nothing to do with this, so no help there.
So I'll try Helmut's suggestions- thanks.
Ian Mitchell, Designer, eaDocX


www.eaDocX.com
www.theartfulmodeller.com

qwerty

  • EA Guru
  • *****
  • Posts: 13570
  • Karma: +395/-301
  • I'm no guru at all
    • View Profile
Re: Another error using SQL
« Reply #5 on: March 15, 2016, 03:53:39 am »
I just copy/pasted the above query and it worked with no issue (EAP, rather recent V12).

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13136
  • Karma: +547/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Another error using SQL
« Reply #6 on: March 15, 2016, 05:28:03 am »
The problem is the unnamed column "count(*)".

If you add AS someName it will work.

This script fragment works without a problem.

Code: [Select]
option explicit

!INC Local Scripts.EAConstants-VBScript


sub main
dim SQLGet
SQLGet = " Select o.name, o.Object_Type, o.Stereotype, COUNT(*) AS count_name from t_object o  " & _
" where o.name is not null " & _
" group by o.name, o.Object_Type, o.Stereotype " & _
" HAVING COUNT(*) > 1"
dim result
result = Repository.SQLQuery(SQLGet)
Session.Output result
end sub

Geert

Ian Mitchell

  • EA User
  • **
  • Posts: 506
  • Karma: +22/-4
  • The eaDocX and Model Expert guy
    • View Profile
Re: Another error using SQL
« Reply #7 on: March 16, 2016, 01:36:36 am »
Pure genius - it works now!
Thanks Geert
Ian Mitchell, Designer, eaDocX


www.eaDocX.com
www.theartfulmodeller.com

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8038
  • Karma: +118/-20
    • View Profile
Re: Another error using SQL
« Reply #8 on: March 16, 2016, 08:42:50 am »
Error: Code = 0x0 Source Line: 0; Char : 0, Error Description = (null).

Interpretation:
The file position of zero zero hints towards this error coming from reading an empty/missing file/string/buffer.

This error structure in EA corresponds to an XML error.

As for differences you saw:
Repository.SQLQuery serializes the response to XML for consumption by the automation client, while a SQL search uses the results directly.
Every different database/ODBC client behaves slightly differently in what it returns. Apparently MySQL returns a column name (or lack of) that prevents the results being serialized to XML.

Ian Mitchell

  • EA User
  • **
  • Posts: 506
  • Karma: +22/-4
  • The eaDocX and Model Expert guy
    • View Profile
Re: Another error using SQL
« Reply #9 on: March 16, 2016, 10:43:37 pm »
Ok - Geert's suggestion fixed that last one - of course - but it has uncovered others.
I've done some more research on this, and I think it may be to do with the size of the results set.
Queries which return large result sets (a 16Mb (string size) definitely throws the error) seem to throw this error - smaller ones don't.
Is there a restriction ?
Ian Mitchell, Designer, eaDocX


www.eaDocX.com
www.theartfulmodeller.com