(Original) using macros in ER/studio to copy attribute name to definition

Source: Internet
Author: User
Document directory
  • Copy attribute name to definition using macros in ER/studio
Copy attribute name to definition using macros in ER/studio

Recently, when processing the SQL script generated by ER/studio, we found that if the definition is not defined, there will be no table and field comments after the SQL script is generated.
Therefore, a macro is written to implement this function. The Code is as follows:
Save the following code as XXX. put the bas file in the macros folder under the ER/studio installation directory, and ER/studio can be automatically loaded to the macros tab, for example, c: \ Program Files \ Embarcadero \ erstudio6.5 \ macros

Dim entcount as integer
Dim colcount as integer
Dim mydigoal as digoal
Dim mymodel as Model
Dim myentity as entity
Dim myattribute as attributeobjdim tablearray () as string
Dim colarray () as string
Function getcolumns (tablename as string)
Dim indx as integer
Dim count as integer
Count = 1
Indx = 0
Set myentity = mymodel. Entities. Item (tablename)
Colcount = myentity. Attributes. Count
Redim colarray (0 to colcount) as string
For Count = 1 to colcount
For each myattribute in myentity. Attributes
If myattribute. sequencenumber = count then
If mymodel. Logical = true then
If myattribute. haslogicalrolename = true then
Colarray (indx) = myattribute. logicalrolename
Else
Colarray (indx) = myattribute. attributename
End if
Else
If myattribute. hasrolename = true then
Colarray (indx) = myattribute. rolename
Else
Colarray (indx) = myattribute. columnname
End if
End if
Myattribute. Definition = colarray (indx)
Indx = indx + 1
End if
Next myattribute
Next count

End Function

Sub main
Debug. Clear
Set mydigoal = diagrammanager. activedigoal
Set mymodel = mydiworkflow. activemodel
Dim indx as integer
Indx = 0
Entcount = mymodel. Entities. Count-1
Redim tablearray (0 to entcount) as string
For each myentity in mymodel. Entities
If mymodel. Logical = true then
Tablearray (indx) = myentity. entityname
Else
Tablearray (indx) = myentity. tablename
End if
Myentity. Definition = tablearray (indx)
Getcolumns (tablearray (indx ))
Indx = indx + 1
Next myentity

End sub

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.