Book a Demo

Author Topic: Does Repository.Execute return a result?  (Read 4508 times)

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Does Repository.Execute return a result?
« on: May 08, 2019, 01:57:27 pm »
My Work Experience Student is too shy to ask here himself...  :)

Does anyone know?

TIA,
Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Does Repository.Execute return a result?
« Reply #1 on: May 08, 2019, 04:09:52 pm »
I've never tried to catch it, but I don't think so.

Enough to test though.

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Does Repository.Execute return a result?
« Reply #2 on: May 08, 2019, 05:41:56 pm »
No. It does not return anything. What would he expect/want to be returned?

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: Does Repository.Execute return a result?
« Reply #3 on: May 08, 2019, 05:59:18 pm »
No. It does not return anything. What would he expect/want to be returned?

q.
Something like affected rows would be useful.

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Does Repository.Execute return a result?
« Reply #4 on: May 08, 2019, 07:09:37 pm »
Seems like you need to run a WHERE query beforehand if you are interested in that number. I never cared about the number of affected rows since I just want it to do the change for whatever had been relevant. But maybe I just did not come across an appropriate use case.

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: Does Repository.Execute return a result?
« Reply #5 on: May 08, 2019, 07:20:11 pm »
Often I find that I want to give feedback to the user indicating what has been changed
(e.g. unlocked 236 elements)
If I want to do that now I need to make a select query first, execute that, get the result from it, and then execute the update query and hope that the result is the same.
I will never be really sure (has the database changed between my select and my update query, did I make a mistake in the select query,...)

If the operation would simply return the affected rows I wouldn't need all of the above, and I would be sure the feedback to the user is correct.

Geert

MaXyM

  • EA User
  • **
  • Posts: 120
  • Karma: +8/-0
    • View Profile
Re: Does Repository.Execute return a result?
« Reply #6 on: May 10, 2019, 06:15:59 pm »
I will never be really sure (has the database changed between my select and my update query, did I make a mistake in the select query,...)

If done in transaction with proper Transiaction Isolation Level (Repeatable Read at least) then you can be sure. But probably not achievable in EA this way.
However EA offers Repository.SQLQuery (string SQL). From reference manual:

Quote
Returns an XML formatted string value of the resulting record set.

BTW mentioned reference doesn't mention Repository.Execute. Maybe it's derived from somewhere else.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Does Repository.Execute return a result?
« Reply #7 on: May 10, 2019, 06:24:01 pm »
I will never be really sure (has the database changed between my select and my update query, did I make a mistake in the select query,...)


If done in transaction with proper Transiaction Isolation Level (Repeatable Read at least) then you can be sure. But probably not achievable in EA this way.
However EA offers Repository.SQLQuery (string SQL). From reference manual:

Quote
Returns an XML formatted string value of the resulting record set.
Sure, that is the workaround we discussed.
Quote
BTW mentioned reference doesn't mention Repository.Execute. Maybe it's derived from somewhere else.
That is on purpose. The Repository.Execute is not documented and not supported by Sparx.
In other words, use at your own risk, and if you get into trouble, you are on your own 8)

Geert