Author Topic: Undocumented command: Repository.Execute  (Read 9793 times)

fwoolz

  • EA User
  • **
  • Posts: 435
  • Karma: +0/-0
  • We have met the enemy, and he is us.<Pogo, 1970>
    • View Profile
Undocumented command: Repository.Execute
« on: June 15, 2010, 03:07:40 pm »
Another one for Sparx:

The AI provides an undocumented Repository method "Execute," which allows an automation client to execute a non-query SQL command (such as "INSERT INTO..." I know this works as of 8.0.857, because I just tried it with the table t_xrefuser). Would Sparx consider changing this from 'undocumented' to 'documented', as it provides add-ins with additional flexibility in accessing the EA database?

Cheers,
Fred W
Fred Woolsey
Interfleet Technology Inc.

Always be ready to laugh at yourself; that way, you beat everyone else to the punch.


mrf

  • EA User
  • **
  • Posts: 311
  • Karma: +0/-0
    • View Profile
Re: Undocumented command: Repository.Execute
« Reply #1 on: June 15, 2010, 03:56:06 pm »
Fred, you know too much. Expect a visit from the lads soon :p

On a more formal note, we do not support or recomend direct manipulation of the database in any form (be it through the automation interface or through a dbms tool). If you're missing functionality, then we'd prefer to provide it through an automation function that can be tested and contained.

The usual disclaimer: we do not take any responsibility for lack of data if you do use Execute() (or an external dbms tool) to modify the underlying database.

PS: As with the custom commands, I would not bank on this undocumented method being in future builds of the automation interface.
« Last Edit: June 15, 2010, 03:58:04 pm by mfraser »
Best Regards,

Michael

[email protected]
"It is more complicated than you think." - RFC 1925, Section 2.8

fwoolz

  • EA User
  • **
  • Posts: 435
  • Karma: +0/-0
  • We have met the enemy, and he is us.<Pogo, 1970>
    • View Profile
Re: Undocumented command: Repository.Execute
« Reply #2 on: June 16, 2010, 01:17:57 am »
Mr. F sez:

I PITY DA FOOL THAT USES UNDOCUMENTED METHODS!

...or, more precisely:

Quote
PS: As with the custom commands, I would not bank on this undocumented method being in future builds of the automation interface.

That's what I was afraid of.

Cheers,
Fred W

PS: You would be safe if Bob Marley rolled by as well...
Fred Woolsey
Interfleet Technology Inc.

Always be ready to laugh at yourself; that way, you beat everyone else to the punch.


RoyC

  • EA Administrator
  • EA Practitioner
  • *****
  • Posts: 1297
  • Karma: +21/-4
  • Read The Help!
    • View Profile
Re: Undocumented command: Repository.Execute
« Reply #3 on: June 16, 2010, 10:21:37 am »
Whether it be Bob Marley or Eric Clapton, I'd still be a nervous posse-member. They might not have shot the deputy, but them deputies still keep on a-dyin'.

I would guess, too, that if I tried to document the undocumented commands, Mr F would lock and load and shout NO MORE JIBBER-JABBER, FOOL! I really would not like that to happen.
« Last Edit: June 16, 2010, 10:31:40 am by RoyC »
Best Regards, Roy

fwoolz

  • EA User
  • **
  • Posts: 435
  • Karma: +0/-0
  • We have met the enemy, and he is us.<Pogo, 1970>
    • View Profile
Re: Undocumented command: Repository.Execute
« Reply #4 on: June 16, 2010, 01:47:41 pm »
I trust that with Mr. F and the rest of the Au-Team on board, Geoff and his posse are safe from sheriff-shooting singers. But now I wonder if I need to buy me some protection from The LadsTM.
Fred Woolsey
Interfleet Technology Inc.

Always be ready to laugh at yourself; that way, you beat everyone else to the punch.


Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Undocumented command: Repository.Execute
« Reply #5 on: June 16, 2010, 03:18:40 pm »
Fred,

Could you post a code snippet on how to use Repository.Execute to execute sql commands?
Could come in handy sometime.

Thanks

Geert

fwoolz

  • EA User
  • **
  • Posts: 435
  • Karma: +0/-0
  • We have met the enemy, and he is us.<Pogo, 1970>
    • View Profile
Re: Undocumented command: Repository.Execute
« Reply #6 on: June 16, 2010, 03:29:54 pm »
Hi Geert,

Here's the (VBScript) code I used to test out the method:

Code: [Select]
' THIS WORKS 2010-06-15
Repository.Execute("INSERT INTO t_xrefuser VALUES ('ABCDEFG','CCC','DDD','1','2','3','4','5','6','7','This is a test','8','9','10')")
Repository.Execute("INSERT INTO t_xrefuser VALUES ('ABCDEFH','CCC','DDD','1','2','3','4','5','6','7','This is a test','8','9','10')")
Session.Output(Repository.SQLQuery("SELECT Client FROM t_xrefuser WHERE XrefID = 'ABCDEFG'"))
Session.Output(Repository.SQLQuery("SELECT XrefID FROM t_xrefuser WHERE Client = '8'"))

The method signature is:

Code: [Select]
void Execute([in] string SQL);
Both the script output and a check of the (.eap) database in Access indicated that the rows had indeed been added.

I haven't tried commands like CREATE TABLE - yet.  ;)

Fred W

PS: I wish Sparx would give us a sandbox in the EA database...
Fred Woolsey
Interfleet Technology Inc.

Always be ready to laugh at yourself; that way, you beat everyone else to the punch.


fwoolz

  • EA User
  • **
  • Posts: 435
  • Karma: +0/-0
  • We have met the enemy, and he is us.<Pogo, 1970>
    • View Profile
Re: Undocumented command: Repository.Execute
« Reply #7 on: June 16, 2010, 03:48:09 pm »
Geert,

Here's the code for a quick test of CREATE TABLE:

Code: [Select]
Repository.Execute("CREATE TABLE u_testtable01 (uID long, uName char)")
A check of the Access database showed that this did in fact create the table with the fields specified.

Apparently the commands for an .EAP file are fed to DAO since DAO error messages result if the syntax isn't right, so command format and data types must be DAO-compatible if your repository is an EAP file.

PS: The modified .EAP file with the added table passes the Project Integrity Test, BTW.

Fred
« Last Edit: June 16, 2010, 03:51:43 pm by fwoolz »
Fred Woolsey
Interfleet Technology Inc.

Always be ready to laugh at yourself; that way, you beat everyone else to the punch.


Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Undocumented command: Repository.Execute
« Reply #8 on: June 16, 2010, 03:57:31 pm »
Ah, that simple  :)

Opens a whole lot of backdoor possibilities.

Thanks Fred.

Geert

SomersetGraham

  • EA User
  • **
  • Posts: 376
  • Karma: +1/-0
    • View Profile
Re: Undocumented command: Repository.Execute
« Reply #9 on: June 16, 2010, 05:14:49 pm »
Hi
Here is how I used Execute
[code]
string query = "UPDATE t_object SET PDATA1='All Scenarios' WHERE Object_ID=" + noteElement.ElementID;
            Repository.Execute(query);
            query = "UPDATE t_object SET PDATA2=" + currentUseCase.ElementID + " WHERE Object_ID=" + noteElement.ElementID;
            Repository.Execute(query);
            query = "UPDATE t_object SET PDATA4='Yes' WHERE Object_ID=" + noteElement.ElementID;
            Repository.Execute(query);
[\code]

HTH

Graham
Using V12

RodneyRichardson

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: Undocumented command: Repository.Execute
« Reply #10 on: May 28, 2025, 02:55:11 am »
Well, Repository.Execute(sql) is still in the API 15 years later (v17)... make of that what you will.

shimon

  • EA User
  • **
  • Posts: 167
  • Karma: +5/-0
    • View Profile
Re: Undocumented command: Repository.Execute
« Reply #11 on: May 28, 2025, 04:12:12 pm »
Documented or not, Perplexity gave it to me when I asked him how to update some diagrams that he helped me create via script. 

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Undocumented command: Repository.Execute
« Reply #12 on: May 28, 2025, 05:47:58 pm »
Well, Repository.Execute(sql) is still in the API 15 years later (v17)... make of that what you will.
I suppose that if they removed that from the API, half of the addins will stop working.

Unfortunately this method is often the only way to achieve certain things as they are not exposed in the API (or only as read-only properties for some reason)

Geert