zoukankan      html  css  js  c++  java
  • (原创)在ER/Studio中使用宏把Attribute name复制到Definition

    在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
  • 相关阅读:
    SQL Server解惑——查询条件IN中能否使用变量
    依赖注入高级玩法——注入接口服务的多个实现类
    最纯净的硬件检测工具箱
    批处理体会hosts文件
    针对m3u8视频的ts文件解密
    HLS协议之m3u8和ts流格式详解
    您的主机不满足在启用Hyper-V或Device/Credential Guard的情况下运行VMwareWorkstation的最低要求
    FFmpeg的安装和使用
    如何下载 blob 地址的视频资源
    Win10系统创建WiFi热点的两种方法
  • 原文地址:https://www.cnblogs.com/jimeper/p/1328968.html
Copyright © 2011-2022 走看看