Book a Demo

Author Topic: VBA how to kill a long loop, each with DB error  (Read 6439 times)

ngong

  • EA User
  • **
  • Posts: 275
  • Karma: +2/-2
    • View Profile
VBA how to kill a long loop, each with DB error
« on: May 13, 2021, 02:01:54 am »
Again, trying to conquer SQL from VBscript I got an annoying problem:

When I have an error in a script using SQL such as
Quote
function getElementsWithMultipleTags()
   set getElementsWithMultipleTags = Repository.GetElementSet( _
      "select * from t_taggedvalue" _
   ,2)
end function

sub main
   dim objects
   Repository.EnsureOutputVisible "Script"
   Repository.ClearOutput "Script"
   set objects = getElementsWithMultipleTags()
   Session.Output "count of elements " & objects.count
end sub

I get the error message DOA.Fields [0x00000cc1] Item not found in this collection in a loop, too many times.
I found no method to stop the execution of the VBscript program (other than killing the EA task).

Is there one, a bit more smooth?

BTW: why is this script wrong? It works with t_object, but not for t_taggedvalue . EASchema_1558.sql shows both tables to be existant.
Rolf

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: VBA how to kill a long loop, each with DB error
« Reply #1 on: May 13, 2021, 06:42:11 am »
GetElementSet wants the element id (aka t_object.object_id) in the first column. t_taggedvalues doesn't have that.

Maybe you want to
Code: [Select]
select object_id from t_objectpropertiesJust guessing...

q.
« Last Edit: May 13, 2021, 06:44:52 am by qwerty »

ngong

  • EA User
  • **
  • Posts: 275
  • Karma: +2/-2
    • View Profile
Re: VBA how to kill a long loop, each with DB error
« Reply #2 on: May 20, 2021, 08:45:43 pm »
Ok, thank you qwerty - now I understand GetElementSet a bit better.
I was looking for a routine given me arbitray result of an SQL query.
However, my routine is working now.
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: VBA how to kill a long loop, each with DB error
« Reply #3 on: May 20, 2021, 08:59:28 pm »
for arbitrairy query results use Repository.SQLQuery

Geert

ngong

  • EA User
  • **
  • Posts: 275
  • Karma: +2/-2
    • View Profile
Re: VBA how to kill a long loop, each with DB error
« Reply #4 on: May 21, 2021, 12:12:43 am »
ok - thanks
BTW - do you have an answer for my first question: "how to kill an endless loop?"
« Last Edit: May 21, 2021, 12:24:03 am by ngong »
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: VBA how to kill a long loop, each with DB error
« Reply #5 on: May 21, 2021, 05:04:54 am »
ok - thanks
BTW - do you have an answer for my first question: "how to kill an endless loop?"
Task manager and kill EA.exe

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: VBA how to kill a long loop, each with DB error
« Reply #6 on: May 21, 2021, 06:01:55 am »
As Geert suggested. It might sound like a harsh solution but EA is not doing anything except interpreting your VBA code. So unless you are doing crucial updates which are not transactionally secured you can kill EA any time. It does not start an independent thread for its VBA interpreter. So no way around that.

q.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: VBA how to kill a long loop, each with DB error
« Reply #7 on: May 21, 2021, 08:26:14 am »
Rather than kill EA, kill SScripter.exe.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: VBA how to kill a long loop, each with DB error
« Reply #8 on: May 21, 2021, 09:23:13 pm »
Oh, so there IS a thread. I was not aware of that, but mainly because I use only external scripting. Proves that my assumptions are not always right.

q.