Book a Demo

Author Topic: Getting next auto-sequence value  (Read 7869 times)

mariusz

  • EA User
  • **
  • Posts: 20
  • Karma: +0/-0
    • View Profile
Getting next auto-sequence value
« 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
« Last Edit: October 05, 2009, 06:31:12 am by kjezyna9 »

mariusz

  • EA User
  • **
  • Posts: 20
  • Karma: +0/-0
    • View Profile
Re: Getting next auto-sequence value
« Reply #1 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...

mariusz

  • EA User
  • **
  • Posts: 20
  • Karma: +0/-0
    • View Profile
Re: Getting next auto-sequence value
« Reply #2 on: October 06, 2009, 01:54:12 am »
I have found:

EA.Repository.Execute();

Nick Webb

  • EA User
  • **
  • Posts: 28
  • Karma: +0/-0
    • View Profile
Re: Getting next auto-sequence value
« Reply #3 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?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Getting next auto-sequence value
« Reply #4 on: October 28, 2009, 11:16:53 pm »
He probably meant
Repository.SQLQuery (string SQL)


Geert

Nick Webb

  • EA User
  • **
  • Posts: 28
  • Karma: +0/-0
    • View Profile
Re: Getting next auto-sequence value
« Reply #5 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

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Getting next auto-sequence value
« Reply #6 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

Pedro Costa

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: Getting next auto-sequence value
« Reply #7 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
« Last Edit: November 05, 2009, 11:41:00 pm by pfcosta »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Getting next auto-sequence value
« Reply #8 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

Pedro Costa

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: Getting next auto-sequence value
« Reply #9 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.

Makulik

  • EA User
  • **
  • Posts: 400
  • Karma: +0/-0
    • View Profile
Re: Getting next auto-sequence value
« Reply #10 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

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Getting next auto-sequence value
« Reply #11 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