Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: mariusz on October 03, 2009, 04:18:00 pm

Title: Getting next auto-sequence value
Post by: mariusz on October 03, 2009, 04:18:00 pm
I'd like to create some model objects by using AI (C#).

How can I get next auto-sequence value, defined for this type of elements? Is it  possible?

mario
Title: Re: Getting next auto-sequence value
Post by: mariusz on October 05, 2009, 11:29:24 pm
Is it possible to make a native sql update operation on table t_trxtypes?

sth like this:

update t_trxtypes set Notes='prefix=SCR;active=1;active_a=0;count=50;' where trx='Class' and Description='Autocount'

It could resolve my problem...
Title: Re: Getting next auto-sequence value
Post by: mariusz on October 06, 2009, 01:54:12 am
I have found:

EA.Repository.Execute();
Title: Re: Getting next auto-sequence value
Post by: Nick Webb on October 28, 2009, 11:06:00 pm
You did?  Can't see that guy anywhere... is there any other way to fire SQL update statements?
Title: Re: Getting next auto-sequence value
Post by: Geert Bellekens on October 28, 2009, 11:16:53 pm
He probably meant
Repository.SQLQuery (string SQL)


Geert
Title: Re: Getting next auto-sequence value
Post by: Nick Webb on October 31, 2009, 12:55:10 pm
thanks geert, but just to clarify.... there is no way of doing an sql update with the api, right?!

Nick
Title: Re: Getting next auto-sequence value
Post by: Geert Bellekens on November 03, 2009, 06:58:42 pm
Quote
thanks geert, but just to clarify.... there is no way of doing an sql update with the api, right?!

Nick

I don't know, I haven't tried. What happens if you pass an update query to the SQLQuery() operation?

Geert
Title: Re: Getting next auto-sequence value
Post by: Pedro Costa on November 05, 2009, 11:15:23 pm
Hi,

Recently i've tried to perform a similar task: to execute INSERT or UPDATE commands into the database. Executing the following line of code returned void and did not interact with the database:

Code: [Select]
Ea.Repository.SQLQuery(" <Update command>")
However if i execute, for instance, the following line of code:

Code: [Select]
Repository.SQLQuery("SELECT 1; <Update command>")
the records of my database are updated, but a weird message box appears in EA. I suppose it is not feasible to alter the information in the database by using the automation interface API?

EDIT:
The "weird message box" contains the following message:

Code: [Select]
---------------------------
EA
---------------------------
Error:
Code = 0x0
Source = Line : 0; Char : 0
Error Description = (null)

---------------------------
OK  
---------------------------



Cheers,

Pedro Costa
Title: Re: Getting next auto-sequence value
Post by: Geert Bellekens on November 06, 2009, 12:43:48 am
Quote
I suppose it is not feasible to alter the information in the database by using the automation interface API?
No, it isn't. In my tools I never update the database directly. It's bad enough I have to resort to selecting stuff from the database from time to time for performance reasons.
Updating the database open a whole other can of worms IMHO.

But if you really want to you can get the connection string from the repository. Based on that you should be able to figure out how to connect to the database directly, and do your updates.

Geert
Title: Re: Getting next auto-sequence value
Post by: Pedro Costa on November 06, 2009, 12:49:55 am
The problem is that the solution that i'm going to develop has it's own data tables. Thus, it is imperative to interact with the database.

I've already tried to use the property Repository.ConnectionString. But there is a major drawback. If the user decides to encrypt it, my addin cannot communicate with the database.
Title: Re: Getting next auto-sequence value
Post by: Makulik on November 06, 2009, 01:10:50 am
Hi Pedro,

Quote
The problem is that the solution that i'm going to develop has it's own data tables. Thus, it is imperative to interact with the database.
I think for this case, you should use your own DAL to manipulate the database, instead of the EA.Repository.SQLQuery() method.

HTH
Günther
Title: Re: Getting next auto-sequence value
Post by: Geert Bellekens on November 06, 2009, 01:30:35 am
Quote
The problem is that the solution that i'm going to develop has it's own data tables. Thus, it is imperative to interact with the database.
Then don't you think it would be wiser to create your own database all together? That migitates the need to update the database of EA. (if you were in my team I wouldn't allow you to touch the database of EA in any way, no updating, and certainly not changing it's structure ;))

Geert