(原创)在ER/Studio中使用宏把Attribute name复制到Definition

简介: 在ER/Studio中使用宏把Attribute name复制到Definition 最近在处理ER/Studio生成SQL脚本时发现,如果在Definition处没有定义,那么在生成SQL脚本后就没有表和字段的注释。

在ER/Studio中使用宏把Attribute name复制到Definition

最近在处理ER/Studio生成SQL脚本时发现,如果在Definition处没有定义,那么在生成SQL脚本后就没有表和字段的注释。
因此就写了一个宏来实现这个功能,代码如下:
把以下代码保存为XXX.bas文件放到ER/Studio安装目录下的Macros的文件夹下,ER/Studio就可以自动加载到Macros选项卡中,如:C:\Program Files\Embarcadero\ERStudio6.5\Macros


Dim EntCount As Integer
Dim ColCount As Integer
Dim MyDiagram As Diagram
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 MyDiagram = DiagramManager.ActiveDiagram
Set MyModel = MyDiagram.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
目录
相关文章
|
C语言 Android开发 Windows
解决windows下eclipse创建project时没有include导致出现“unresolved inclusion: <stdio.h>”错误的方法
解决windows下eclipse创建project时没有include导致出现“unresolved inclusion: <stdio.h>”错误的方法
解决windows下eclipse创建project时没有include导致出现“unresolved inclusion: <stdio.h>”错误的方法
|
4月前
|
图形学
小功能⭐️Unity动态更改 Scripting Define Symbols (宏定义)
小功能⭐️Unity动态更改 Scripting Define Symbols (宏定义)
|
7月前
|
C++
Qt定义属性类信息报错‘Qstring‘ was not declared in this scope; did you mean ‘xxx‘?并且还有有一堆报错,问题还出现在moc文件
Qt定义属性类信息报错‘Qstring‘ was not declared in this scope; did you mean ‘xxx‘?并且还有有一堆报错,问题还出现在moc文件
119 0
|
编译器
[√]添加预处理的2个不同方式:target_compile_definitions / add_definitions
[√]添加预处理的2个不同方式:target_compile_definitions / add_definitions
255 0
|
XML Java 应用服务中间件
Push to origin/master was rejec、enum+switch枚举搭配使用、idea 如何进入debug;Error during artifact deployment. S
Push to origin/master was rejec、enum+switch枚举搭配使用、idea 如何进入debug;Error during artifact deployment. S
201 0
Push to origin/master was rejec、enum+switch枚举搭配使用、idea 如何进入debug;Error during artifact deployment. S
|
C语言 流计算
利用gcc的__attribute__编译属性section子项构建初始化函数表【转】
转自:https://my.oschina.net/u/180497/blog/177206 gcc的__attribute__编译属性有很多子项,用于改变作用对象的特性。这里讨论section子项的作用。
2387 0