Book a Demo

Author Topic: Bulk rename columns  (Read 5339 times)

Yves Mulkers

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Bulk rename columns
« on: October 15, 2015, 06:16:00 pm »
Is there an easy way to rename columns in bulk?

I have a model with column names with a fixed strings in which a typo was made.
Looking for a quick way to overcome a tedious job...

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Bulk rename columns
« Reply #1 on: October 15, 2015, 06:29:30 pm »
Hey Yves,

There's not really a standard "bulk edit" mode, but there are other solutions.
In cases like this I usually make an SQL update query to correct the problem.

Something like:

Code: [Select]
update t_attribute set name = 'newname' where name = 'oldname'Just make sure [highlight]ALL [/highlight]attributes with 'oldname' may be renamed.

Then make a little VBScript (in EA's scripting module) like this:
Code: [Select]
sub main
      dim updateSQL
      updateSQL = "update t_attribute set name = 'newname' where name = 'oldname'"
      Repository.Execute updateSQL
      Repository.RefreshModelView(0)
      msgbox "Finished"
end sub

Executing that script will rename all columns.

Of course you have to test this on a test environment to make sure that it does what it should.

Another solution could be to export to XMI, search and replace in the XMI file, and then import the XMI again.

Geert

Yves Mulkers

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: Bulk rename columns
« Reply #2 on: October 15, 2015, 07:13:46 pm »
Thanks Geert.

For the xmi export, I'm puzzled... all options are greyed out.
Did try an apply user lock, but still...

any idea?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Bulk rename columns
« Reply #3 on: October 15, 2015, 07:21:02 pm »
Do you have the security rights to export to xmi?

Apply userlock should not be necessary for an export (since you won't be changing anything).

Geert