Author Topic: Update EA Repository Query  (Read 1599 times)

dangel

  • EA User
  • **
  • Posts: 74
  • Karma: +0/-0
    • View Profile
Update EA Repository Query
« on: September 05, 2015, 06:32:42 am »
I do not find Repository.Execute (SQL) to update tables in Enterprise Architecture using C# + Ea.Repository
I am using Enterprise Architecture v 10.0
  I want to insert/update  values into table t_connector using  my Add-Ins
           Repository.SQLQuery(SQL_Query);// for query
but there is no functions for update/execute in EA 10.0, how can  I solve this issue in order to insert/update statements in EA Repository
« Last Edit: September 05, 2015, 07:31:46 am by dangel »

dangel

  • EA User
  • **
  • Posts: 74
  • Karma: +0/-0
    • View Profile
Re: Update EA Repository Query
« Reply #1 on: September 05, 2015, 07:50:12 am »
Any suggestion please

qwerty

  • EA Guru
  • *****
  • Posts: 8960
  • Karma: +136/-123
  • I'm no guru at all
    • View Profile
Re: Update EA Repository Query
« Reply #2 on: September 05, 2015, 08:05:17 am »
It is not an officially documented method. So auto-completion does not work. Anyhow, it is present and works. Just write it by hand.

q.

dangel

  • EA User
  • **
  • Posts: 74
  • Karma: +0/-0
    • View Profile
Re: Update EA Repository Query
« Reply #3 on: September 05, 2015, 08:14:30 am »
Thanks a lot for replay,
here is my example:
 String SQL_Query = @"UPDATE t_propertytypes SET t_propertytypes.Property='000' where notes='abc' ";            
// Repository.SQLQuery(SQL_Query); // does not work for Update/Insert
How can I then Execute such query from Add-ins /c# ! ? any alternative solutions ? API ?
please give me some details,

Thanks again for your answer

Regards,
« Last Edit: September 05, 2015, 08:58:24 am by dangel »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 7733
  • Karma: +165/-21
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Update EA Repository Query
« Reply #4 on: September 05, 2015, 04:00:09 pm »
Quote
It is not an officially documented method. So auto-completion does not work. Anyhow, it is present and works. Just write it by hand.

q.
Code: [Select]
Repository.Execute(SQL_Query);
qwerty already gave you the answer, you just have to read it.

Geert

cjcrystal

  • EA Novice
  • *
  • Posts: 15
  • Karma: +0/-0
    • View Profile
Re: Update EA Repository Query
« Reply #5 on: September 14, 2017, 03:24:35 pm »
May I ask further in relation to the UpdateSQL,

Is there an issue, or can a Script user update information if they have a lesser  access permissions than the orginal data Author when using an update SQL ?

for example:

User 1('The Administrator') is , the  data Author  with more access permissions, and created the data in  t_object table

while the User 2 ('The Script user') running an UpdateSQL ( ) script has a lower access permission, and wants to update data create by 'The Administrator'  in t_object  table.

Both users having Update Element permission.

VKN

  • EA User
  • **
  • Posts: 155
  • Karma: +8/-0
    • View Profile
Re: Update EA Repository Query
« Reply #6 on: September 14, 2017, 03:55:28 pm »
Repository.Execute(sql) doesn't check for any permissions other than the permission to run the script itself.

cjcrystal

  • EA Novice
  • *
  • Posts: 15
  • Karma: +0/-0
    • View Profile
Re: Update EA Repository Query
« Reply #7 on: September 14, 2017, 04:25:57 pm »
thanks  VKN

qwerty

  • EA Guru
  • *****
  • Posts: 8960
  • Karma: +136/-123
  • I'm no guru at all
    • View Profile
Re: Update EA Repository Query
« Reply #8 on: September 14, 2017, 06:07:34 pm »
EA's security is no security ar all. Except you declare the key under the doormat a security feature. It's sort of "accidental deletion prevention".

q.

Eamonn John Casey

  • EA User
  • **
  • Posts: 83
  • Karma: +0/-0
    • View Profile
Re: Update EA Repository Query
« Reply #9 on: September 21, 2017, 02:39:26 am »
I have been using the API extensively and especially the SQLQuery. The API just like the SQL Scratch Pad rejects anything that is not SELECT.
The work-around (and this is really dangerous in some conditions) is to go direct to the database using your favorite DB API.

Please post the SQL you are attempting. Maybe there is some API or easier way.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 7733
  • Karma: +165/-21
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Update EA Repository Query
« Reply #10 on: September 21, 2017, 01:23:24 pm »
I have been using the API extensively and especially the SQLQuery. The API just like the SQL Scratch Pad rejects anything that is not SELECT.
The work-around (and this is really dangerous in some conditions) is to go direct to the database using your favorite DB API.

Please post the SQL you are attempting. Maybe there is some API or easier way.

Jon, have you never tried Repository.Execute()? That is a whole lot easier then to make your own db connection and execute a query that way.

Geert

Eamonn John Casey

  • EA User
  • **
  • Posts: 83
  • Karma: +0/-0
    • View Profile
Re: Update EA Repository Query
« Reply #11 on: September 21, 2017, 07:21:15 pm »
Geert,
Yes. Tried that. But what I was trying to point out was directly manipulating the database bypasses a certain amount of logic. So you need to know what you are doing. Often one update results in lots of small updates in other places in the database. So this also must be replicated.
EjC

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 7733
  • Karma: +165/-21
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Update EA Repository Query
« Reply #12 on: September 21, 2017, 07:46:38 pm »
Geert,
Yes. Tried that. But what I was trying to point out was directly manipulating the database bypasses a certain amount of logic. So you need to know what you are doing. Often one update results in lots of small updates in other places in the database. So this also must be replicated.
EjC
Indeed. There's a reason why this operation is hidden and unsupported by Sparx.
If you decide to use it you better know what you are doing.

Geert